【问题标题】:Xamarin ios song does not always play on speakerXamarin ios 歌曲并不总是在扬声器上播放
【发布时间】:2021-10-15 12:32:33
【问题描述】:

我是用户 Xamarin fomrs text to Speech api click here to see

我已经设法在我的应用程序上实现了它,但有时歌曲会在手机扬声器上播放,有些人会在录制歌曲后在耳机上讲话

问题:

如何让歌曲始终在手机的扬声器上播放

代码如下:

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");

感谢您的帮助

【问题讨论】:

  • 对您有帮助吗?

标签: c# .net xamarin.forms xamarin.ios azure-cognitive-services


【解决方案1】:

关键是使用适当的AVAudioSessionCategory 调用SetCategory 并将会话设置为活动状态。

喜欢:

var session = AVAudioSession.SharedInstance();
session.SetCategory(AVAudioSessionCategory.Playback);
session.SetActive(true);

您可以在您的ios项目中使用DependencyService进行设置。您可以参考https://docs.microsoft.com/en-us/answers/questions/320860/isimpleaudioplayer-issues-on-ios-and-with-speechre.html

【讨论】:

  • Leo Zhu AVAudioSession.SharedInstance 在我的 xamarin 表单代码文件中无法识别
猜你喜欢
  • 2012-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-17
  • 1970-01-01
相关资源
最近更新 更多