How can i add/change speech voice gender to iOS app in swift? I am using AVSpeechSynthesisvoice Class for getting speech voices
Asked Answered
S

2

10

I have created an app with speech voice feature using AVSpeechSynthesizer & displaying a list of languages from AVSpeechSynthesisVoice: speechVoices() function in a TableView. The user can select speech language from the TableView.

The next thing i wanted to achieve is to add speech gender so that user can switch between default Male or Female voices like in Siri app. I do not want to make it complex so just looking for default Male or Female voices.

The voices returned from speechVoices() have a default Male or Female voice specific to each voice.

Can I change it anyhow ? I have placed a UIPickerView on app settings page to select between male and Female voices.

However, I did some research but could not found any documentation. Seems there is no such support available till latest iOS release.

Did anyone tried to implement such feature so far?

Studious answered 9/3, 2016 at 21:3 Comment(2)
Can anyone please comment or share some thoughts?Studious
I am wondering the same thing! Did you (or somebody) figure this out?Maroney
A
0

I think you don't have that information, and each voice is male or female, so you would have to categorise all available voices for the languages your are working with, so that on runtime you can sort them using this information. That's something I would be very willing to use on my app.

Archaeornis answered 6/1 at 3:44 Comment(0)
S
-1
    //NSArray* voices = AVSpeechSynthesisVoice.speechVoices;
    //voice identifier inspection reports
    //com.apple.ttsbundle.Samantha-compact
    //com.apple.speech.synthesis.voice
    //AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:text];
    //Replace hard-coded name with any available in the list pulled from the speechVoices array

    NSUInteger idx = [AVSpeechSynthesisVoice.speechVoices indexOfObjectPassingTest:^BOOL(AVSpeechSynthesisVoice * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
      return [obj.identifier containsString:@"Samantha"];
    }];
    if (idx > -1) {
      AVSpeechSynthesisVoice* voice = AVSpeechSynthesisVoice.speechVoices[idx];
      utterance.voice = voice;
    }
Shier answered 15/10, 2018 at 23:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.