Save tts as audio file

Asked

Viewed 456 times

4

How can I generate an audio file from a TexttoSpeech to share with other services (sms, Whats, messenger, ...)?

I created this function to share

private void shareAudio() 
{
    Intent intent = new Intent( Intent.ACTION_SEND );
    intent.setType("audio/3gpp");
    startActivity( intent );
}

but I have no idea how to "treat" tts before, any idea?

1 answer

0

Alternative 1

The library Texttospeech does not support audio recording, however, may try to enter recording mode while you speak through the class Mediarecord:

MediaRecorder minhaRecorder = new MediaRecorder();

To start a recording, you need to use the methods prepare() and start():

minhaRecorder.prepare();
minhaRecorder.start();

A Texttospeech can only be used to synthesize text.

It is important to note that not all languages are supported by API Texttospeech. Therefore it is interesting to execute the method isLanguageAvailable to see whether or not you can use a particular language in this structure.

Alternative 2

This would be another alternative, if you didn’t want to use the user’s voice. You can use Google Translator to read the text that was capitured by voice and convert to MP3. Then your job would be to save this MP3 inside your application, but it would only work if you have Internet, because you would access Google Translator in real time. See the link below using the word "test".

http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=Teste&tl=Pt

Details

  • But you say capture (from the microphone) the sound of tts? There is no way to transform tts into a string or something of the type, and from that string to generate an mp3 with tts voice which can be shared?

  • @pokemon_cwb I say capture from the microphone the sound of the voice of the person who is speaking using tts. But the issue of transforming string into voice, would also give to use google translator api.

  • @pokemon_cwb edited the reply by placing the google translator link as alterative 2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.