Implementing TTS in Android (for self voicing)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3795
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Implementing TTS in Android (for self voicing)

#1 Post 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?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Implementing TTS in Android (for self voicing)

#2 Post 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...
Frameworks & Scriptlets:

User avatar
ComputerArt.Club
Veteran
Posts: 427
Joined: Mon May 22, 2017 8:12 am
Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
Location: Taiwan
Contact:

Re: Implementing TTS in Android (for self voicing)

#3 Post by ComputerArt.Club »

Wow, let us know how this works out for you! I've also wondered about this before.

User avatar
Andredron
Miko-Class Veteran
Posts: 722
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Implementing TTS in Android (for self voicing)

#4 Post by Andredron »

Good afternoon, has there been any progress since the fast? I'm curious to know the result.

Post Reply

Who is online

Users browsing this forum: No registered users