Skip to content

Commit

Permalink
fix(example): move provider creation into try block
Browse files Browse the repository at this point in the history
  • Loading branch information
kxxt committed May 20, 2022
1 parent e3b1b44 commit 6773d57
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/examples/line_by_line.py
Expand Up @@ -6,13 +6,12 @@

from aspeak import SpeechServiceProvider, pure_text_to_speech, AspeakError

provider = SpeechServiceProvider()
output = AudioOutputConfig(use_default_speaker=True)

tts = partial(pure_text_to_speech, provider, output)

if __name__ == "__main__":
try:
provider = SpeechServiceProvider()
tts = partial(pure_text_to_speech, provider, output)
while True:
result = tts(input("Enter text to speak: "))
if result.reason != ResultReason.SynthesizingAudioCompleted:
Expand Down
2 changes: 1 addition & 1 deletion src/examples/simple.py
Expand Up @@ -3,11 +3,11 @@

from aspeak import SpeechServiceProvider, text_to_speech, AudioFormat, FileFormat, AspeakError

provider = SpeechServiceProvider()
output = AudioOutputConfig(use_default_speaker=True)

if __name__ == "__main__":
try:
provider = SpeechServiceProvider()
result = text_to_speech(provider, output, "Hello World! I am using aspeak to synthesize speech.",
voice="en-US-JennyNeural", rate="+10%", pitch="-5%", style="cheerful",
audio_format=AudioFormat(FileFormat.WAV, 1))
Expand Down

0 comments on commit 6773d57

Please sign in to comment.