Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkParker5 committed Jun 28, 2023
1 parent 5a3ec6e commit cf51f3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions majordom_va/IO/GCloudSpeechSynthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def stop(self):

class GCloudSpeechSynthesizer(SpeechSynthesizer):

def __init__(self, name = 'ru-RU-Wavenet-B', language_code = config.language_code):
def __init__(self, name = config.voice_name, language_code = config.language_code):
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = config.goole_tts_json_key
self._client = texttospeech.TextToSpeechClient()
self._audio_config = texttospeech.AudioConfig(audio_encoding = texttospeech.AudioEncoding.LINEAR16)
Expand All @@ -37,8 +37,8 @@ def __init__(self, name = 'ru-RU-Wavenet-B', language_code = config.language_cod
)

def synthesize(self, text) -> Speech:
dir = f'audio/{self._name}'
path = f'{dir}/{self._transliterate(text)[:100]}.wav'
folder = f'audio/{self._name}'
path = f'{folder}/{self._transliterate(text)[:100]}.wav'

if os.path.exists(path):
return Speech(text, self._name, path)
Expand All @@ -47,8 +47,8 @@ def synthesize(self, text) -> Speech:

try:
response = self._client.synthesize_speech(input = synthesis_input, voice = self._voice, audio_config = self._audio_config)
if not os.path.exists(dir):
os.makedirs(dir)
if not os.path.exists(folder):
os.makedirs(folder)
with open(path, 'wb') as out:
out.write(response.audio_content)
except Exception as e:
Expand Down
7 changes: 6 additions & 1 deletion majordom_va/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# Google Cloud TTS
goole_tts_json_key: str = 'downloads/gc-tts-key.json'
language_code: str = 'ru-RU'
voice_name: str = 'ru-RU-Wavenet-B'

# Silero TTS
silero_model_url: str = 'https://models.silero.ai/models/tts/ru/ru_v3.pt'
silero_model_url: str = 'https://models.silero.ai/models/tts/ru/ru_v3.pt'

# Picovoice Porcupine (Wakeword)
porcupine_key: str = ''
porcupine_keyword_path: str = 'downloads/porcupine-keywords.txt'

0 comments on commit cf51f3e

Please sign in to comment.