Skip to content

Instantly share code, notes, and snippets.

@tommasodeponti
Created April 22, 2020 12:42
Show Gist options
  • Save tommasodeponti/0faecd439640dc7a2388aceb4a6d8303 to your computer and use it in GitHub Desktop.
Save tommasodeponti/0faecd439640dc7a2388aceb4a6d8303 to your computer and use it in GitHub Desktop.
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