Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print("Generating...")
for i in sorted(np.random.choice(len(dataset), n_samples)):
mel, wav_gt = dataset[i]
# out_gt_fpath = fileio.join(gen_path, "%s_%d_gt.wav" % (model_name, i))
# out_pred_fpath = fileio.join(gen_path, "%s_%d_pred.wav" % (model_name, i))
wav_gt = audio.unquantize_signal(wav_gt)
if use_mu_law:
wav_gt = audio.expand_signal(wav_gt)
sd.wait()
sd.play(wav_gt, 16000)
wav_pred = inference.infer_waveform(mel, normalize=False) # The dataloader already normalizes
sd.wait()
sd.play(wav_pred, 16000)
# audio.save_wav(out_pred_fpath, wav_pred)
# audio.save_wav(out_gt_fpath, wav_gt)
print('')
sd.wait()
speaker_id = "user_%02d" % i
i += 1
speaker_embed = encoder.embed_utterance(wav_source)[None, ...]
else:
speaker_embed, speaker_id, wav_source = get_random_embed()
print(speaker_id)
# Synthesize the text with the embedding
text = input("Text: ")
mel = synth.my_synthesize(speaker_embed, text)
wav_griffin = inv_mel_spectrogram(mel.T, hparams)
wav_griffin = np.concatenate((wav_griffin, [0] * hparams.sample_rate))
print("Griffin-lim:")
sd.play(wav_griffin, 16000)
wav_wavernn = vocoder.infer_waveform(mel.T)
wav_wavernn = np.concatenate((wav_wavernn, [0] * hparams.sample_rate))
sd.wait()
print("\nWave-RNN:")
sd.play(wav_wavernn, 16000)
sd.wait()
save_wav(wav_source, "../%s_%s.wav" % (speaker_id, "source"), 16000)
save_wav(wav_griffin, "../%s_%s.wav" % (speaker_id, "griffin"), 16000)
save_wav(wav_wavernn, "../%s_%s.wav" % (speaker_id, "wavernn"), 16000)
os.makedirs(out_dir, exist_ok=True)
#mel_file = os.path.join(mel_folder, mel_file)
from vlibs import fileio
# fnames = fileio.listdir('logs-two_outputs/mel-spectrograms/')
fnames = fileio.listdir('tacotron_output/eval/')
for i in range(1, len(fnames)):
# mel_file = 'logs-two_outputs/mel-spectrograms/mel-prediction-step-110000.npy'
mel_file = fileio.join('tacotron_output/eval/', fnames[i])
mel_spectro = np.load(mel_file) #.transpose()
wav = inv_mel_spectrogram(mel_spectro.T, hparams)
sounddevice.wait()
print(fnames[i])
sounddevice.play(wav, 16000)
sounddevice.wait()
quit()
save_wav(wav, os.path.join(out_dir, 'test_mel_{}.wav'.format(mel_file.replace('/', '_').replace('\\', '_').replace('.npy', ''))),
sr=hparams.sample_rate)
# In[3]:
from tacotron.utils.plot import *
plot_spectrogram(mel_spectro, path=os.path.join(out_dir, 'test_mel_{}.png'.format(mel_file.replace('/', '_').replace('\\', '_').replace('.npy', ''))))
# In[4]:
def play(self, wav, sample_rate):
sd.stop()
sd.play(wav, sample_rate)
if keyword not in words and plural.plural(keyword) not in words:
continue
try:
# occurance in audio
start_ms, end_ms = util.parse_srt_time(cc_time)
except Exception as exception:
cp.print_error(exception)
continue
cp.print_instruction("How many time was the keyword spoken? (\"r\" to replay audio)\n", "[ " + cc_text + " ]")
while True:
try:
time.sleep(0.5)
sd.play(audio_data[start_ms:end_ms], blocking=True)
sd.stop()
user_input = input()
audio_count = int(user_input)
except ValueError:
if user_input != "r":
cp.print_error("Invalid Input. Expect Integer")
continue
else:
break
# occurance in captions
cc_count = 0
for word in words:
if word == plural.plural(keyword):
cc_count += 1
def play(self, src):
sd.play(pra.normalize(src) * 0.75, samplerate=self.fs, blocking=False)
def play(self, key):
if not self.key_audio_map.get(str(key)):
self.key_audio_map[str(key)] = key % self.non_unique_count
data, fs = self.sound_effect_cache[self.key_audio_map[str(key)]]
data = data * self.configer.volume
fs = fs * self.configer.pitch
threading.Thread(target=sd.play, args=(data, fs)).start()
def stop_recording():
global waveform
actual_time = time.time()-start_time
sd.stop()
samples = min(int(actual_time*sd.default.samplerate), len(waveform))
waveform = waveform[0:samples, 0]
get_axes().clear()
spectrum, freqs, t, im = get_axes().specgram(waveform,
Fs=sd.default.samplerate)
redraw()
sd.play(waveform)
time.sleep(float(len(waveform))/sd.default.samplerate)
return np.transpose(spectrum)
finalWavelets.append(wtOriginal)
for morphed in morphedWavelets:
finalWavelets.append(morphed)
finalWavelets.append(wtTarget)
waveletHelper.plotWavelets(finalWavelets)
# waveletHelper.plotWavelets([finalWavelets[0]])
# waveletHelper.plotWavelets([finalWavelets[1]])
# waveletHelper.plotWavelets([finalWavelets[2]])
audio = waveletHelper.audioFromWavelets(finalWavelets)
sounddevice.play(audio, sampleRate)
i = 1
# time.sleep(4)