MCPcopy Create free account
hub / github.com/rawpython/remi / on_say

Method on_say

examples/text_to_speech_app.py:91–105  ·  view source on GitHub ↗
(self, widget)

Source from the content-addressed store, hash-verified

89 'callback_function': '_voices_callback'})
90
91 def on_say(self, widget):
92 text = self.text_input.get_text()
93 pitch = self.pitch_slider.get_value()
94 rate = self.rate_slider.get_value()
95 print("Saying: {} at rate {} and pitch {}".format(text, rate, pitch))
96 self.execute_javascript(
97 """
98 var synth = window.speechSynthesis;
99 voices = synth.getVoices();
100 var utterThis = new SpeechSynthesisUtterance("{}");
101 utterThis.pitch = {};
102 utterThis.rate = {};
103 utterThis.voice = voices[{}];
104 synth.speak(utterThis);
105 """.format(text, pitch, rate, self.selected_voice_id))
106
107# starts the web server
108start(MyApp, address="0.0.0.0", port=9990)

Callers

nothing calls this directly

Calls 3

execute_javascriptMethod · 0.80
get_textMethod · 0.45
get_valueMethod · 0.45

Tested by

no test coverage detected