Skip to content

Commit

Permalink
Removed PyAudio from the project
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinJ committed Jun 17, 2019
1 parent 42cb5d3 commit 77028db
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You will need the following whether you plan to use the toolbox only or to retra

**Python 3.7**. Python 3.6 might work too, but I wouldn't go lower because I make extensive use of pathlib.

Run `pip -r requirements.txt` to install the necessary packages. Additionally you will need [PyTorch](https://pytorch.org/get-started/locally/), PyQt4 (Linux: package `python-qt4`, [Windows](https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4)) and [PyAudio](https://people.csail.mit.edu/hubert/pyaudio/).
Run `pip -r requirements.txt` to install the necessary packages. Additionally you will need [PyTorch](https://pytorch.org/get-started/locally/) and PyQt4 (Linux: package `python-qt4`, [Windows](https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4)).

A GPU is *highly* recommended (CPU-only is currently not implemented), but you don't necessarily need a high tier GPU if you only want to use the toolbox.

Expand Down
29 changes: 0 additions & 29 deletions synthesizer/synthesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,11 @@
from synthesizer.hparams import hparams_debug_string
from synthesizer.infolog import log
import tensorflow as tf
from time import sleep
from tqdm import tqdm
import time
import os


def generate_fast(model, text):
model.synthesize(text, None, None, None, None)

def run_live(args, checkpoint_path, hparams):
#Log to Terminal without keeping any records in files
log(hparams_debug_string())
synth = Synthesizer()
synth.load(checkpoint_path, hparams)

#Generate fast greeting message
greetings = "Hello, Welcome to the Live testing tool. Please type a message and I will try " \
"to read it!"
log(greetings)
generate_fast(synth, greetings)

#Interaction loop
while True:
try:
text = input()
generate_fast(synth, text)

except KeyboardInterrupt:
leave = "Thank you for testing our features. see you soon."
log(leave)
generate_fast(synth, leave)
sleep(2)
break

def run_eval(args, checkpoint_path, output_dir, hparams, sentences):
eval_dir = os.path.join(output_dir, "eval")
log_dir = os.path.join(output_dir, "logs-eval")
Expand Down
23 changes: 1 addition & 22 deletions synthesizer/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from synthesizer.utils import plot
import tensorflow as tf
import numpy as np
import pyaudio
import wave
import os

Expand Down Expand Up @@ -181,27 +180,7 @@ def synthesize(self, texts, basenames, out_dir, log_dir, mel_filenames, embed_fi
assert len(mels) == len(linears) == len(texts)

if basenames is None:
#Generate wav and read it
wav = audio.inv_mel_spectrogram(mels.T, hparams)
audio.save_wav(wav, "temp.wav", sr=hparams.sample_rate) #Find a better way

chunk = 512
f = wave.open("temp.wav", "rb")
p = pyaudio.PyAudio()
stream = p.open(format=p.get_format_from_width(f.getsampwidth()),
channels=f.getnchannels(),
rate=f.getframerate(),
output=True)
data = f.readframes(chunk)
while data:
stream.write(data)
data=f.readframes(chunk)

stream.stop_stream()
stream.close()

p.terminate()
return
raise NotImplemented()

saved_mels_paths = []
for i, mel in enumerate(mels):
Expand Down

0 comments on commit 77028db

Please sign in to comment.