Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 06: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

From Wiki
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();
}
This page was last modified on 26 July 2012, at 06:16.
714 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×