Add compatibility for windows
This commit is contained in:
parent
a69f8c1fac
commit
7e862fe3d3
2 changed files with 13 additions and 7 deletions
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
simpleaudio
|
||||||
|
git+https://github.com/jyapayne/espeak-phonemizer
|
||||||
|
git+https://github.com/jyapayne/mimic3
|
||||||
17
tts.py
17
tts.py
|
|
@ -14,6 +14,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
|
import os
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
|
@ -117,14 +118,16 @@ def create_mimic3_system(
|
||||||
return mimic3
|
return mimic3
|
||||||
|
|
||||||
def play_wav_bytes(wav_bytes: bytes):
|
def play_wav_bytes(wav_bytes: bytes):
|
||||||
with tempfile.NamedTemporaryFile(mode="wb+", suffix=".wav") as wav_file:
|
wav_file = tempfile.NamedTemporaryFile(mode="wb+", suffix=".wav", delete=False)
|
||||||
wav_file.write(wav_bytes)
|
wav_file.write(wav_bytes)
|
||||||
wav_file.seek(0)
|
wav_file.seek(0)
|
||||||
|
wav_file.close()
|
||||||
|
|
||||||
filename = wav_file.name
|
filename = wav_file.name
|
||||||
wave_obj = sa.WaveObject.from_wave_file(filename)
|
wave_obj = sa.WaveObject.from_wave_file(filename)
|
||||||
play_obj = wave_obj.play()
|
play_obj = wave_obj.play()
|
||||||
play_obj.wait_done()
|
play_obj.wait_done()
|
||||||
|
os.unlink(filename)
|
||||||
|
|
||||||
def say_words(words: str, mimic3: Mimic3TextToSpeechSystem, length_scale: float = None, ssml=False):
|
def say_words(words: str, mimic3: Mimic3TextToSpeechSystem, length_scale: float = None, ssml=False):
|
||||||
"""Thread handler for synthesis requests"""
|
"""Thread handler for synthesis requests"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue