text to speech conversion

后端 未结 3 374
挽巷
挽巷 2021-01-22 13:46

We are making iPhone app where client want reminder as voice message.

Requirement is user will set time and text they want for for reminder.

Using text, I will c

相关标签:
3条回答
  • 2021-01-22 14:27

    This works iOS 7 onwards ONLY

    Below is the code I used.

    NSString *myStr;
    
    //    myStr = @"Hello friend, how are you?";
    myStr = @"مرحبا صديق، كيف حالك؟";
    
    AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
    
    AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:myStr];
    [utterance setRate:0.2f];
    //    utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-us"];
    utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"ar-SA"];
    [synthesizer speakUtterance:utterance];
    

    Imports used are

    #import <AVFoundation/AVFoundation.h>
    #import <QuartzCore/QuartzCore.h>
    

    Languages supported are as below.

    Arabic (Saudi Arabia) - ar-SA
    Chinese (China) - zh-CN
    Chinese (Hong Kong SAR China) - zh-HK
    Chinese (Taiwan) - zh-TW
    Czech (Czech Republic) - cs-CZ
    Danish (Denmark) - da-DK
    Dutch (Belgium) - nl-BE
    Dutch (Netherlands) - nl-NL
    English (Australia) - en-AU
    English (Ireland) - en-IE
    English (South Africa) - en-ZA
    English (United Kingdom) - en-GB
    English (United States) - en-US
    Finnish (Finland) - fi-FI
    French (Canada) - fr-CA
    French (France) - fr-FR
    German (Germany) - de-DE
    Greek (Greece) - el-GR
    Hindi (India) - hi-IN
    Hungarian (Hungary) - hu-HU
    Indonesian (Indonesia) - id-ID
    Italian (Italy) - it-IT
    Japanese (Japan) - ja-JP
    Korean (South Korea) - ko-KR
    Norwegian (Norway) - no-NO
    Polish (Poland) - pl-PL
    Portuguese (Brazil) - pt-BR
    Portuguese (Portugal) - pt-PT
    Romanian (Romania) - ro-RO
    Russian (Russia) - ru-RU
    Slovak (Slovakia) - sk-SK
    Spanish (Mexico) - es-MX
    Spanish (Spain) - es-ES
    Swedish (Sweden) - sv-SE
    Thai (Thailand) - th-TH
    Turkish (Turkey) - tr-TR
    

    Reference

    0 讨论(0)
  • 2021-01-22 14:27

    Starting from iOS7, Apple already provide that in its SDK as per below:

    Apple documentation

    0 讨论(0)
  • 2021-01-22 14:42

    Use AVSpeechSynthesizer

    AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
    AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Some random text that you want to be spoken"];
    [utterance setRate:0.7];
    [synthesizer speakUtterance:utterance];
    

    Reference

    0 讨论(0)
提交回复
热议问题