iOS Text to Speech

UIText2Speech adds text to speech and auto language translation for over 90 languages and 500 language locales to any app easily. Uses Google Text to Speech and Translation API. This package includes full source code and a working demo. View Pricing
scroll down for more

Visual and programmatic text-to-speech on iOS

UIText2Speech consists of two parts: the visual controls and a rich API for integrating text to speech processing, translation between languages, creation of MP3 speech audio files and a UIText2Speech control to playing audio while showing the audio waveform. Uses Google Text to Speech and Translation API.

See Apple AppStore mText2Speech iOS universal app which is one of the many apps using this UIText2Speech API.

Use the UIText2Speech control to play text to speech results in your app or just use the API to add text to speech and language translation to any app.

Visual Control

UIText2Speech is a UIView subclass used to show a waveform of audio from text converted to speech or an audio file and can do auto translation to convert from one language to another. The resulting MP3 audio is played and a waveform representing the playing audio is shown.

The UIText2Speech control can play audio for text converted to speech or for a regular audio file. The component when playing highlights the area of the waveform that corresponds to portion of the audio being played.

Optional area for showing text of audio being played. If text auto translated to another language, then shows original language text and translated text.

Component displays running time and total time when playing audio and showing waveform.

Custom button and text colors can be used to style the component. Normal and minimal display modes available.

Rich API

The API static methods can be used to easily add text to speech functionality to your app. You can read text in a specific language, translate text between languages, detect the language for text, create an MP3 audio of read or translated text, play audio for read or translated text, determine all the available locales and languages available.

The UIText2Speech control uses the API.

Features

  • Add saying of text in any language you desire to your app.
  • Auto translate text to translate text from one language to another.
  • Load and play text spoken in default or a specific language and show a visual waveform of the audio played.
  • Load and play an audio file and show visual waveform.
  • Automatically translate text between languages.
  • Manually translate text between languages using the API.
  • Show original and translated text.
  • Manage and use locales and locale identifiers.
  • Detect language text is in.
  • Get an MP3 audio file for text using the API.
  • Share an MP3 audio file to Email, Facebook, Twitter and other services.
  • Play audio file using component or AVAudioPlayer.
  • Customizable text and colors.
  • Minimal display mode for component displaying just play/pause button.

iOS Support

This project supports iOS 7, iOS 8, iOS 9 and iOS 10.

Pricing

14 day 14-day money-back guarantee

$9.99

Single App

  • Perpetual license

  • 1 application

  • Can distribute binary products only

  • Commercial use

  • 1 month support

$29.99

Developer

  • Perpetual license

  • Unlimited projects

  • Can distribute code and binary products

  • Commercial use

  • 12 months support

Setup / installation

To install Text2Speech for your app, create a Text2Speech group within your app project and drag the files from the Text2Speech folder into the folder. Be sure to copy the files and set the target for the files to your app.

Required Frameworks and Libraries

Must include the following frameworks: CoreMedia, CoreGraphics, CoreFoundation, AudioToolbox, AVFoundation, MediaPlayer, Foundation, UIKit, MessageUI, SystemConfiguration.

Example usage

// Example 1 - use API to translate and speak text

// translate text to Spanish then say the text
NSString * textToSay = @"Just starting the demo application.";
NSString * esTextToSay = [UIText2Speech translateTextToLocaleIdentifier:textToSay toLocaleIdentifier:@"es_AR" autoDetectLanguage:TRUE];
[UIText2Speech readText:esTextToSay localeIdentifier:@"es_AR"];
NSLog(@"Speaking the English text '%@' in Spanish '%@'", textToSay, esTextToSay);

// Example 2 - this example gets the MP3 audio for the English to French translation of the text.
//             The UIText2Speech component shows a waveform of the playing audio file.
//
// English text
NSString * textToSay = @"Starting the demo application.";

// Translation notes:  translation from one language to another and creation of
// audio file for spoken text if done using Google Translate web services.  Check
// the UIText2Speech API for details.   See the full working demo for changing the key 
// used for Google Translate if you are using the translation.   You should use your 
// own Google key to tracks things and the supplied one expires in 30 days.
//
// You can do the translation yourself for full control or you can
// use autoTranslate to let the component do the translation, if it is necessary.
// The auto translation detection works pretty well and only has problems if the text
// has language elements that make it appear to be the target language.   i.e. English text
// that has some French syntax or very similar words.   In those cases manual translation 
// can a better selection.   You can decide....

int componentWidth = self.view.frame.size.width - 20;

// Translate English text to French
// show visual waveform of text being said in French
// Auto-play audio of speech

// do the translate here from English to French.  You can do the translate before using the API or ask the component to do the translation.
NSString * frTextToSay = [UIText2Speech translateTextToLocaleIdentifier:textToSay toLocaleIdentifier:@"fr_FR" autoDetectLanguage:TRUE];
NSLog(@"Saying %@", frTextToSay);
//
// Do not auto translate supplied text since we already did the translation ourselves
// Autoplay audio once audio loads
// Do not show fields for text and original text shown since we did translation.
//        If we show fields then only translated text is shown

text2Speech = [[UIText2Speech alloc] initWithFrame:CGRectMake(10, 10, componentWidth, 90) text:frTextToSay textLocaleIdentifier:@"fr_FR" autoTranslate:FALSE autoPlay:TRUE showTextField:FALSE];
// other options:
//[text2Speech setVerbose:TRUE];     // use to turn verbose mode on
//[text2Speech setButtonColor:[UIColor redColor]];   // use to set the color used for the play/pause button
//[text2Speech setTextColor:[UIColor yellowColor]];  // use to set the color used for the text
//[text2Speech restoreButtonColor];    // use to restore the button color to the default
//[text2Speech restoreTextColor];      // use to restore the text color to the default
[self.view addSubview:text2Speech];
NSLog(@"get text back %@ (original %@)", [text2Speech getText], [text2Speech getOriginalText]);


// Example 3 - this example gets the MP3 audio for the English to Spanish translation of the text
//             The UIText2Speech component shows a waveform of the playing audio file.
//
// Translate English text to Spanish
// Auto translate supplied text from English to Spanish
// Show fields for translated and original text
// Do not Auto-play audio of speech
//
text2Speech2 = [[UIText2Speech alloc] initWithFrame:CGRectMake(10, 140, componentWidth, 90) text:textToSay textLocaleIdentifier:@"es_AR" autoTranslate:TRUE autoPlay:FALSE showTextField:TRUE];
[self.view addSubview:text2Speech2];