Pyjnius android Text to speech in Bengali , Hindi,and other languages

109 views
Skip to first unread message

Degenerate Tech

unread,
Dec 27, 2020, 3:56:28 PM12/27/20
to Kivy users support
#I want text to speech in Bengali, hind,and 
other languages .. please tell me how to do that 

from jnius import autoclass
Locale = autoclass('java.util.Locale')
PythonActivity = autoclass('org.renpy.android.PythonActivity')
TextToSpeech = autoclass('android.speech.tts.TextToSpeech')
tts = TextToSpeech(PythonActivity.mActivity, None)

# Play something in english
tts.setLanguage(Locale.US)
tts.speak('Hello World.', TextToSpeech.QUEUE_FLUSH, None)

# Queue something in french
tts.setLanguage(Locale.FRANCE)
tts.speak('Bonjour tout le monde.', 



purushottam yadav

unread,
Nov 8, 2022, 1:32:14 AM11/8/22
to Kivy users support
did you find out ....?   in my case the code does not even make the app speak  ,  there no sound  . 

Robert

unread,
Nov 8, 2022, 1:48:40 AM11/8/22
to Kivy users support
Don't know what jnius does with a Java Set, but you can experiment.....

I don't have an example.

purushottam yadav

unread,
Nov 8, 2022, 4:19:27 AM11/8/22
to Kivy users support

In https://developer.android.com/reference/android/speech/tts/TextToSpeech   you can find below statement at very beginning of the page  ,

how to do it in kivy ..?     


Apps targeting Android 11 that use text-to-speech should declare TextToSpeech.Engine.INTENT_ACTION_TTS_SERVICE in the queries elements of their manifest:

<queries> ... <intent> <action android:name="android.intent.action.TTS_SERVICE" /> </intent> </queries>

Robert

unread,
Nov 8, 2022, 12:01:15 PM11/8/22
to Kivy users support

> how to do it in kivy ..?     

It is possible that buildozer.spec enables this:

1)  research where the <queries> element belongs in the AndroidManifest.
2) research if any of the the buildozer.spec that alter the AndroidManifest enable this.

I have not done this research.

Mohit Narwani

unread,
Nov 8, 2022, 12:11:41 PM11/8/22
to Kivy users support
actually even if u don't put anything in mainfest it will still work

purushottam yadav

unread,
Nov 8, 2022, 12:19:26 PM11/8/22
to Kivy users support
why do think it is not working in my case ..?
what is your device's android versions , 11 ..?

Mohit Narwani

unread,
Nov 8, 2022, 12:39:13 PM11/8/22
to kivy-...@googlegroups.com
I have tested in various devices including android 13 that i already told you. I am also not sure why it is not working. By the way kya project hai apka? 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/79540b44-8084-431f-b00e-9cbe96f8faban%40googlegroups.com.

purushottam yadav

unread,
Nov 8, 2022, 12:50:26 PM11/8/22
to Kivy users support
what are the versions of  pythonforandroid , kivy , buildozer  , pyjnius are you using ..?
Not a project  , just trying tts . 

purushottam yadav

unread,
Nov 9, 2022, 3:16:28 AM11/9/22
to Kivy users support
this is my code , any corrections or suggestions ...?
please leave your  code here  , which you tried on android 13 device .




        from jnius import autoclass

        Locale = autoclass('java.util.Locale')
        #PythonActivity = autoclass('org.renpy.android.PythonActivity')
        PythonActivity = autoclass('org.kivy.android.PythonActivity')


        TextToSpeech = autoclass('android.speech.tts.TextToSpeech')
        

        tts = TextToSpeech(PythonActivity.mActivity, None)

        # Play something in english
        tts.setLanguage(Locale.US)

        tts.speak( "aavakaayaa" , TextToSpeech.QUEUE_FLUSH, None)
        print(dir( tts  ) )
        print( "here......." , tts )
        print( tts.getAvailableLanguages( )  )

Mohit Narwani

unread,
Nov 10, 2022, 8:50:42 AM11/10/22
to Kivy users support
Reply all
Reply to author
Forward
0 new messages