Created
April 22, 2020 12:42
-
-
Save tommasodeponti/0faecd439640dc7a2388aceb4a6d8303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.uix.button import Button | |
from kivy.uix.textinput import TextInput | |
from kivy.uix.boxlayout import BoxLayout | |
import pyttsx3 | |
def say(text): | |
engine = pyttsx3.init() | |
voices = engine.getProperty('voices') | |
engine.setProperty('voice', voices[0].id) | |
engine.say(text) | |
engine.runAndWait() | |
class SpeechSynthesisApp(App): | |
def build(self): | |
layout = BoxLayout() | |
self.text_field = TextInput(hint_text='Enter Text Here') | |
button = Button(text="Perform Speech Synthesis", on_press=self.perform) | |
layout.add_widget(self.text_field) | |
layout.add_widget(button) | |
return layout | |
def perform(self, action): | |
text = self.text_field.text | |
say(text) | |
SpeechSynthesisApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment