Text-to-speech/speech-to-text

Good day,

I am building a chatbot into my web app on anvil. I need help with text-to-speech and speech-to-text. I will really appreciate any simple example…

Thank you

1 Like

Welcome @omolewah! Haven’t done something like that yet. But Anvil has lots of packages available for free!

Hi @omolewah, and welcome to the forum!

To use speech synthesis and recognition from the browser, you’ll need to interface with Javascript and use the browser’s SpeechRecognition and SpeechSynthesis interfaces.

You can learn more about using Javascript from Anvil here:

https://anvil.works/docs/client/javascript

And you can learn more about the web speech APIs from Mozilla here:


As we’re still on our holiday break, I’m going to resist the temptation to put together a demo. But if someone feels inspired to wrap this up into a library that can be imported as an Anvil dependency, that would make a very worthy contribution to the Anvil Library!

2 Likes

Besides the javascript, is this all there is to text-to-speech? See top image.
If I just want to experiment with it in the Anvil designer without publishing, do I still need to use javascript?
I can’t find much on the web about how to use javascript to interface for python for tts.
What about Pyttsx? I have the code on the bottom, it seems very simple. I tried “import pyttsx” in the anvil designer, it said no such module.

image

You could definitely work out how to record the audio on the client and then send that to a server module, then handle the speech recognition in python

You might find this related post useful

Here is a small example that takes the example script from MDN
and makes it python/anvil using https://anvil.works/docs/client/javascript
(It only works on Chrome)

DzK7Hg9FIT

Stu - could you make a quickie example of how Anvil can speak “Hello World” or point me in the right direction? I am also trying to get Anvil to talk ! Thank you!

Here’s a quick demo of text to speech

it uses the demo from MDN as a reference:

And here’s the live app:

3 Likes

wow thank you Stu - going through this app now - amazing!


Which dependency is it trying to load? Seems to be trouble…

Sorry about that - try now - should be fixed

1 Like

this is awesome - works perfectly… thanks again Stu!