Gaussian noise generation for a given SNR ?
Since nobody answered this question yet, i'm going to do my best to do it. Be aware i'm no expert on DSP.

I believe your first function is calculating the signal and noise average power based on each one's Fourier Transforms. So you're returning the SNR in decibels at the end.

\begin{equation}
SNR_{db} = 10 * \log_{10}{\frac{P_{signal}}{P_{noise}}}
\end{equation}

Your gaussian noise function generates the noise based on a scaling factor k of the signal max amplitude. Since you want to scale the amplitude of the noise based on your signal, i believe you want a relationship of:

\begin{equation}
k=\frac{A_{noise}}{A_{signal}}
\end{equation}

With each A meaning RMS amplitude. That can be generated used the following equation:

\begin{equation}
k = \sqrt{\frac{1}{SNR_{linear}}}
\end{equation}

or, to be more clear:

\begin{equation}
k = \sqrt{\frac{P_{noise}}{P_{signal}}} =\sqrt{\frac{A_{noise}^2}{A_{signal}^2}}
\end{equation}

If you were given the SNR in decibels and was asked to generate a noise based on it, you can use the following equation:

\begin{equation}
k = \frac{1}{10^{\frac{SNR_{db}}{10}}}
\end{equation}

In the third function you're generating the output signal by adding the frequency components of each signal, but if it's just an additive gaussian noise, you could just add the noise to the signal. (I'm not exactly sure on this).

You could also generate the linear SNR from your SNR in decibels, I've used this function in one of my projects once:

def linear_snr_from_db(snrdb):
    return 10.0 ** (snrdb/10.0)


I got all of the equations based on the wikipedia page for SNR and my little bit of experience.