Page 1 of 1

Implementing TTS in Android (for self voicing)

Posted: Thu Jul 11, 2019 6:42 pm
by Imperf3kt
I believe I asked about this one before and I'm looking into it again.

What is like to do is make the self voicing function work on Android devices.

In my looking around, I found gTTS
https://pypi.org/project/gTTS/
Which can be used with Python

Code: Select all

from gtts import GTTS
import os
tts = gTTS(text='Hello world', lang='en')
tts.save("hello.mp3")
os.system("mpg321 hello.mp3")
As I understand it, the text that shows in a say window is not actually text, but an image created from the script. I was wondering how I might get that text into the gTTS module?

I also found iOS TTS

Code: Select all

import speech
speech.say('Hola mundo', 'es_ES')
Which can also record speech

Code: Select all

import sound

r = sound.Recorder('audio.m4a')
r.record(3)  # seconds
And convert it to text (for renpy.input?)

Code: Select all

text = speech.recognize('audio.m4a', 'en')[0][0]  # sent to Apple servers
http://omz-software.com/pythonista/docs/ios/speech.html



Anybody got any tips to getting these to work with Ren'Py?

Re: Implementing TTS in Android (for self voicing)

Posted: Thu Jul 11, 2019 9:05 pm
by Remix
Though I've not tried any of this myself (yet), I'd suggest looking at plyer (https://github.com/kivy/plyer) as a wrapper api into pyjnius on droid or pyobjus on ios.
If you got plyer talking to pyjnius correctly you could hook into the text of your VN by using config.say_menu_text_filter and passing the text off to the TTS function before returning it to Ren'Py for display...

Re: Implementing TTS in Android (for self voicing)

Posted: Sun Jul 14, 2019 10:08 am
by ComputerArt.Club
Wow, let us know how this works out for you! I've also wondered about this before.

Re: Implementing TTS in Android (for self voicing)

Posted: Fri Apr 19, 2024 8:24 am
by Andredron
Good afternoon, has there been any progress since the fast? I'm curious to know the result.