Document Navigation SDK for iOS Guides Voice Guidance Text-to-Speech

Text-to-Speech

Voice Guidance (TTS)

Starting from Navigation SDK v5.5.0, AMapNaviBaseManager provides a property that lets you use the built-in system speech synthesizer for navigation announcements. This feature is supported for driving, walking, and cycling navigation. When set to YES, the Navigation SDK uses the iOS system's built-in speech synthesis to play announcements — no additional setup is required.

/// Whether to use the built-in TTS for navigation announcements.
/// When set to YES, the Navigation SDK handles voice playback.
/// Default is NO. Available since v5.5.0.
@property (nonatomic, assign) BOOL isUseInternalTTS;

In addition, the SDK provides callbacks that pass the announcement text content to your app. If you prefer not to use the built-in TTS, you can integrate a third-party speech synthesis SDK to convert the text into audio and handle navigation announcements yourself.

The following table lists the relevant interfaces and callbacks:

Navigation Type

Class Name

Interface / Callback

Description

Driving

<AMapNaviDriveManagerDelegate>

driveManager:playNaviSoundString:soundStringType:

Callback for navigation announcement text. Must be used together with driveManagerIsNaviSoundPlaying:.

driveManagerIsNaviSoundPlaying:

Return whether voice is currently playing. Return YES if playing, NO otherwise.

Walking

AMapNaviWalkManager

-setTTSPlaying:

Set whether an external voice is currently playing. Pass YES if playing, NO otherwise.

<AMapNaviWalkManagerDelegate>

walkManager:playNaviSoundString:soundStringType:

Callback for navigation announcement text. Must be used together with -setTTSPlaying:.

Cycling

AMapNaviRideManager

-setTTSPlaying:

Set whether an external voice is currently playing. Pass YES if playing, NO otherwise.

<AMapNaviRideManagerDelegate>

rideManager:playNaviSoundString:soundStringType:

Callback for navigation announcement text. Must be used together with -setTTSPlaying:.

Usage

The following example demonstrates using the system speech synthesizer for driving navigation.

- (BOOL)driveManagerIsNaviSoundPlaying:(AMapNaviDriveManager *)driveManager
{
    return [[SpeechSynthesizer sharedSpeechSynthesizer] isSpeaking];
}

- (void)driveManager:(AMapNaviDriveManager *)driveManager playNaviSoundString:(NSString *)soundString soundStringType:(AMapNaviSoundType)soundStringType
{
    NSLog(@"playNaviSoundString:{%ld:%@}", (long)soundStringType, soundString);
    
    [[SpeechSynthesizer sharedSpeechSynthesizer] speakString:soundString];
}

Important: Ensure that driveManagerIsNaviSoundPlaying: returns the correct Boolean value. If it always returns YES, the SDK assumes that voice is always playing, and driveManager:playNaviSoundString:soundStringType: will never be triggered — resulting in no announcement text. If it always returns NO, announcements may play too frequently, causing speech to be interrupted. Always return the actual playback status.

Setting Language and Announcement Mode

[AMapServices sharedServices].regionLanguageType = AMapRegionLanguageTypeEn;
    
    NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"AudioResources_XXX" ofType:@"bundle"];
    NSLog(@"bundlePath: %@", bundlePath);
    AMapNaviAppLangOptions *options = [[AMapNaviAppLangOptions alloc] init];
    options.voicePath = bundlePath ? : @"";
    [AMapNaviDriveManager setAppLang:options authCallback:^(BOOL isAuthSuc) {
        
    }];