Skip to content

Commit

Permalink
clean unused variable & excessive comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ggh committed Aug 26, 2023
1 parent 84cc1af commit a265f12
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions yacyac_io/yacyac_io/tts.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/usr/bin/env python3

"""Synthesizes speech from the input string of text or ssml.
Make sure to be working in a virtual environment.
Note: ssml must be well-formed according to:
https://www.w3.org/TR/speech-synthesis/
"""
from google.cloud import texttospeech
import os
import playsound
Expand All @@ -19,26 +13,21 @@
class SpeakTTS(Node):
def __init__(self):
super().__init__("yacyac_io")
self.is_speak = False

self.srv = self.create_service(TTS, '/yacyac/io', self.callback_service)
# Instantiates a client
self.client = texttospeech.TextToSpeechClient()
# Build the voice request, select the language code ("en-US") and the ssml
# voice gender ("neutral")

self.voice = texttospeech.VoiceSelectionParams(
language_code="ko-KR", ssml_gender=texttospeech.SsmlVoiceGender.FEMALE
)
# Select the type of audio file you want returned

self.audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.MP3
)

def callback_service(self, request, response):
response.tts_str_s = request.tts_str_t

# Set the text input to be synthesized
text = str(response.tts_str_s)
print(text)
synthesis_input = texttospeech.SynthesisInput(text=text)

self.response = self.client.synthesize_speech(
Expand All @@ -49,18 +38,16 @@ def callback_service(self, request, response):
out.write(self.response.audio_content)

playsound.playsound('output.mp3', block=False)

return response




def main(args=None):
rp.init(args=args)
tts_service = SpeakTTS()
rp.spin(tts_service)
rp.shutdown()


if __name__ == '__main__':
main()

0 comments on commit a265f12

Please sign in to comment.