My application needs to run a silent mp3 in background.
I use TTS synthesizetofile() to convert text to mp3 and TTS playsilence() for playing silence.
While I can easily convert normal text to mp3 I cant figure out an easy way to play silence.
For those who would suggest don't play anything for x duration and that will be silence...it will not solve my objective. Because if nothing is being played that would allow other sound application to assume that nothing is being played while here I need a silent pause.
Secondly, when nothing is being played, android by default shuts down the application.
Also, the solution is not to create a silent mp3 file manually and put into the application because the pause keeps varying and also dependent on values chosen by the user.
Also, TTS playsilence will not do the job because android does not consider it as background music application and shuts it down in like 5 seconds.
Thanks!
I found a solution myself and sharing for those who would come looking for it here...
Use the same TTS.synthesizetofile() method but instead of text use the text in code below:
<speak version="1.1" ><break time="1500ms" /></speak>
replace 1500ms here with any duration you want either in seconds or milliseconds like "3s" or "3000ms"
Related
Now like does the question says, I need a way to play a small sound that lasts for like 1 second or less to play really quickly/fast in my Xamarin Android app. I am using .mp3 files and MediaPlayer class, is there any way to get as fast as possible to play a particular sound?
This question has a background for iOS but I am also asking in general.
I am developing an app that requires to start and stop playing an audio file at specific points on the timeline. Apart from finding out the duration of play by substracting the start-time from the stop-time and use the duration to set a separate timer to stop the audio play, is there a more effective way (an exact way) to control the stop?
Currently, my app, under the influence of its "weather" that the stop could be near or far, occasionally the stop will come too late and part of the audio after the specified stop point is played.
Now, I have examined audio editing program namely Audacity, by selecting a range on the timeline and hit play, Audacity starts and stops (at least to the naked ear or the feeble mind) precisely at the specified points. What is the underlying control mechanism and how it differs to iOS API?
Could iOS employ the same or similar mechanism? How about Android?
Much appreciated.
With Android u can start and stop the playback of a audiofile
at the axactly time in milliseconds also like in audacity.
In audacity the time is formated like this 00h00m00.000s.
The Time after the "." are the milliseconds , so u have to transfer both times to milliseconds.
Than u can seek to the start time and stop after the (start-stop)-time difference with a handler.
See here Android: How to stop media (mp3) in playing when specific milliseconds come?
but why u not cut the specific segment in audacity?
I am trying to make an app that plays a sound like a piano organ. When the user presses a button it will play a piano-like sound. The difficulty is that the user could hold their finger down for any length of time. When they lift their finger off the should fade rather than stop abruptly.
I've played with SoundPool and Media Player but they don't seem suitable.
There are a lot of piano apps out there... does anyone know how they solve this problem?
You'll want to use the AudioTrack class. The basic usage is to write your sound data using AudioTrack's write() method for whatever duration that you want it to be heard. You'll need to use a separate thread for each simultaneous voice that you want to "play".
Here's the AudioTrack reference page and here's a blog entry where the author does a nice job of showing what to do without a lot of distractions.
While developing TextToSpeech got a doubt that if we pause the activity how can we pause the TextToSpeeh along with the activity...If we resume the activity the text to speech will start where it has stopped previously...
How can we achieve this?
Thanks..
The TTS SDK doesn't have any pause functionality that I know of. But you could use synthesizeToFile() to create an audio file that contains the TTS output. Then, you would use a MediaPlayer object to play, pause, and stop playing the file. Depending on how long the text string is, it might take a little longer for audio to be produced because the synthesizeToFile() function would have to complete the entire file before you could play it, but this delay should be acceptable for most applications.
how to fast forwarding an Audio file using media player in android on seekbar progress change?
I would use the 'seekTo()'-method and jump about 10 or 20 seconds each time.
I don't think MediaPlayer can do much more than play/pause actually. I'm using SoundPool non-stop, so someone should correct me if I'm wrong here.
I think you might need to add different versions of the song (with different speed) and change the actual source each time you want to speed up.