AVSpeechSynthesizer有一个相当简单的API,它不支持保存到内置的音频文件.
我想知道是否有办法解决这个问题 - 可能会录制输出,因为它是静音播放,以后播放?或者更高效的东西.
问题:在iOS 7.x和iOS 8.x中,此代码运行正常,但在iOS 9.x中,与iOS 7和8中的语音速率相比,语音速度变慢.
self.synthesizer = [[AVSpeechSynthesizer alloc] init];
self.synthesizer.delegate = self;
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:[NSString stringWithFormat:@"Hey %@, please choose places to explore or select excursions to see our custom crafted deals",[defaults objectForKey:@"USERNAME"]]];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
utterance.rate = 0.10;
[self.synthesizer speakUtterance:utterance];
Run Code Online (Sandbox Code Playgroud) HI有没有人在iOS 8上试过AvSpeechSynthesizer?我在Xcode 6上做了快速的应用程序,但没有音频出来,我在Xcode 5上运行同样的工作并且没有任何障碍.
示例代码来自http://nshipster.com/avspeechsynthesizer/
NSString *string = @"Hello, World!";
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:string];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
[speechSynthesizer speakUtterance:utterance];
Run Code Online (Sandbox Code Playgroud)
Xcode6的错误?
==编辑===看起来像iOS 8 sim的bug /问题,iOS7.1 Sim与Xcode6工作正常..
是否有任何方法或未记录的技巧来更改 AVSpeechSynthesizer 说出单词或短语的方式?我并不是要求改变整个句子的音调或语速。我想改变句子某些部分的语音变化或语调。
如果没有,哪些 SDK 或 API 可以实现此目的?
是否可以在语音合成器中使用增强/高品质的声音(美国的Alex)?我已经下载了声音,但没有办法告诉合成器使用它而不是默认声音.
由于声音通常是由BCP-47编码选择的,并且只有美国英语,因此似乎没有办法进一步区分声音.我错过了什么吗?(人们会认为Apple可能已经考虑过对不同方言的需求,但我没有看到它).
TIA.
我需要的是单独使用左声道或右声道播放音频。我知道 AVAudioPlayer 可以使用 pan 属性使用任一通道播放音频。如果 AVSpeechSynthesizer 无法实现这一点,是否可以使用 AVAudioPlayer 播放话语以便控制通道?如果我能以某种方式获取 AVSpeechUtterance 的 NSURL 并使用 AVAudioPlayer 播放它?
只有以前的类似问题:有什么方法可以控制 AVSpeechSynthesizer 输出到哪个音频通道?我发现没有答案,我在试图找到解决方案时却一无所获。
我不知道为什么会出现这个错误。我得到的错误是
由于未捕获的异常“com.apple.coreaudio.avfaudio”而终止应用程序,原因:“所需条件为假:_recordingTap == nil”
更新
实际上,这是可行的,但几次之后,按钮突然被禁用,麦克风不再工作。然后它会导致错误并崩溃。
你能帮我解决这个问题吗?
class ViewController: UIViewController, SFSpeechRecognizerDelegate, UITextViewDelegate, AVSpeechSynthesizerDelegate {
@IBOutlet weak var myTextView: UITextView!
@IBOutlet weak var microphoneButton: UIButton!
private let speechRecognizer = SFSpeechRecognizer(locale: Locale.init(identifier: "en-US"))!
private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest?
private var recognitionTask: SFSpeechRecognitionTask?
private let audioEngine = AVAudioEngine()
var rightButton = UIBarButtonItem()
override func viewDidLoad() {
super.viewDidLoad()
microphoneButton.isEnabled = false
speechRecognizer.delegate = self
speechRecognizerFunc()
myTextView.delegate = self
myTextView.isUserInteractionEnabled = false
}
@IBAction func cancelButton(_ sender: UIBarButtonItem) {
self.dismiss(animated: true, completion: nil)
}
func speechRecognizerFunc(){ …Run Code Online (Sandbox Code Playgroud) iOS SDK 7.0中引入了AVSpeechSynthesisVoice.voiceWithLanguage。那时,每种语言/地区只有一种声音。
自iOS SDK 9.0起,每种语言/地区都添加了更多声音。因此,Apple引入了新的API voiceWithIdentifier,以便您可以获取所需的特定语音。
我的问题是,如果我们仍在iOS 9或更高版本中使用voiceWithLanguage,该怎么办?该API究竟返回什么?更重要的是,返回的语音是否在iOS版本之间甚至在不同设备之间发生了变化?
我注意到,voiceWithLanguage返回的内容有点依赖于iOS语音设置“设置->常规->辅助功能->语音->语音->英语”。但并不是完全匹配。就是说,例如英语US,如果将语音设置为“ Fred”,voiceWithLanguage将返回“ Fred”,这很酷。但是,如果将语音设置为“ Nicky”,voiceWithLanguage会返回“ Nicky”以外的其他内容。
我问这是因为我的应用程序正在使用voiceWithLanguage。当用户将iOS升级到iOS 12时,他们报告说他们听到了不同的声音。我相信voiceWithLanguage在升级到iOS 12后会返回不同的声音。虽然我无法在相同类型的设备上重现它。
当然,我可以开始改用voiceWithIdentifier。但是只是对带语音的voiceWithLanguage感到好奇。
更新
我在另一台设备上安装了 iOS 13 GM,没有遇到此问题。所以我不再确定这是否是 iOS 13 GM 特有的,或者是我安装它的方式的问题。在第一台设备(iPhone X)上,我进行了升级(通过 iTunes 中的“选项键 + 检查更新按钮”)。在第二台设备(iPhone SE)上,我进行了完整恢复。尚不确定是什么导致它进入这种状态。
原始问题
AVSpeechSynthesisVoice.speechVoices()报告称,当我在装有 iOS 13 GM 的设备上运行它时,没有可用的语音。事实上,当我尝试使用AVSpeechSynthesisVoice(identifier:)它加载语音时,它总是返回零。它在模拟器中工作。我不认为这是以前的测试版的问题,而且它似乎适用于 iOS 13.1 beta 2 和 3。
有没有人遇到过这种情况,并想出任何解决方法?我没有看到任何有意更改此行为的文档,因此我怀疑这是一个错误。我打算提交雷达。但这对于即将发布的 iOS 13 来说并没有什么帮助。
在新创建的单视图项目中可以重现此行为,并将以下简单viewDidLoad功能添加到包含的视图控制器中。
override func viewDidLoad() {
super.viewDidLoad()
let voices = AVSpeechSynthesisVoice.speechVoices()
print("Voice Count: \(voices.count)")
}
Run Code Online (Sandbox Code Playgroud)
输出很长:
2019-09-11 10:43:09.370992-0400 SpeechTest[1617:412065] Creating client/daemon connection: C591307C-313E-4B5F-91A8-184B7E662819
2019-09-11 10:43:09.396250-0400 SpeechTest[1617:412065] Got the query meta data reply for: com.apple.MobileAsset.MacinTalkVoiceAssets, response: 0
2019-09-11 10:43:09.397519-0400 SpeechTest[1617:412065] Consumed extension
2019-09-11 10:43:09.401982-0400 SpeechTest[1617:412065] Got …Run Code Online (Sandbox Code Playgroud) 是否可以在 iOS 应用程序中自动加载新的语音合成语音?多种高质量的“增强”声音可供下载Settings > Accessibility > Spoken Content > Voices > English。我想使用其中一种高质量的应用程序,但不想向应用程序用户解释他们必须通过深入“设置”导航来手动下载它们。
Siri 声音似乎是我手机上预装的唯一高质量声音,不幸的是 Apple 不允许我们在 AVSpeech\xe2\x80\x8bSynthesizer 中使用这些声音。(选择其中之一作为 AVSpeechSynthesisVoice\xe2\x80\x94 例如
\n\nlet utterance = AVSpeechUtterance(string: "This is a test.")\nutterance.voice = AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.siri_female_en-US_premium")\nspeechSynthesizer.speak(utterance)\nRun Code Online (Sandbox Code Playgroud)\n\n没有影响;而是使用质量较低的默认语音。)
\nios ×7
objective-c ×3
swift ×2
audio ×1
avfoundation ×1
ios13 ×1
ios9 ×1
iphone ×1
voice ×1
xcode7 ×1