I am user Xamarin fomrs text to speech api click here to see
I have manage to implemented it on my app but some time the song play on phone speaker and some speak on earphone after record the song
Question:
How to make the song always play on phone's speaker
Here is the code :
var config = SpeechConfig.FromSubscription("xxxx", "xxxx");
config.SpeechSynthesisVoiceName = MicosoftTranslater.MySpeakerlanguagesList( "fr-FR");
var synthesizer = new SpeechSynthesizer(config);
await synthesizer.SpeakTextAsync("I am playing from phone speaker");
Thanks for your help
The key is calling the SetCategory
with the appropriate AVAudioSessionCategory
and setting the session to active.
Like:
var session = AVAudioSession.SharedInstance();
session.SetCategory(AVAudioSessionCategory.Playback);
session.SetActive(true);
You could use DependencyService to set it in your ios project.You could refer to https://learn.microsoft.com/en-us/answers/questions/320860/isimpleaudioplayer-issues-on-ios-and-with-speechre.html.