Namespaces
Variants
Actions
Revision as of 09:16, 26 July 2012 by hamishwillee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Text to speech in Symbian 2nd and 3rd edition phones

Jump to: navigation, search
Article Metadata

Article
Created: giridharn (22 May 2007)
Last edited: hamishwillee (26 Jul 2012)

Text to Speech in Symbian 2nd and 3rd edition phones

Latest S60 devices from Nokia (starting from N70 and N90) include speaker independent name dialing (SIND) and enhanced voice commands. You don't have to train your phone voice dialing anymore. To make a call you simply need to push the voice key and say the name from the phonebook. SIND feature is closed for third party developers. However,there is a shortcut for using the Text-to-Speech part of SIND. You can make your phone synthesize a piece of arbitrary text by passing a specially formed descriptor to the CMdaAudioPlayerUtility.

iPlayer->OpenDesL( _L8( "(tts)Say this" ) );

The speech quality is too low for synthesizing emails or even single sentences, but is sufficient for pronouncing one-two words expected by the user. It can really be used in your program for synthesizing names, "left", "right", maybe addresses. Note that this code example will work on hardware only. It can be compiled also for WINS, but on emulator the playback requests will fail with KErrNotSupported. Apparently the text-to-speech libraries are not included into the SDK distribution.


// Prefix telling the audio utility that TTS should be used
_LIT( KTtsPrefix, "(tts)" );
 
void CTtsPlayer::PlayTextL( TDesC& aText )
{
__ASSERT_ALWAYS( iPlaybackInProgress == EFalse, User::Leave( KErrNotReady ) );
 
HBufC8* playableText = HBufC8::NewLC( aText.Length() + KTtsPrefix().Length() );
 
playableText->Des().Append( KTtsPrefix );
playableText->Des().Append( aText );
 
iPlayer->OpenDesL( *playableText );
iPlaybackInProgress = ETrue;
iWaiter->Start();
 
// At this point playback is already completed or failed
User::LeaveIfError( iErr );
CleanupStack::PopAndDestroy( playableText );
}
 
void CTtsPlayer::MapcInitComplete( TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/ )
{
iErr = aError;
 
if( aError != KErrNone )
{
iPlaybackInProgress = EFalse;
// Let the paused PlayTextL complete
iWaiter->AsyncStop();
}
else
{
iPlayer->Play();
}
}
 
void CTtsPlayer::MapcPlayComplete( TInt aError )
{
iErr = aError;
iPlaybackInProgress = EFalse;
// Let the paused PlayTextL complete
iWaiter->AsyncStop();
}
131 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved