Description
ezSpeech ANE
AIR Native Extension for Android & iOS mobile projects
Version 1.5.0
Bring the power of voice to your mobile projects. With ezSpeech ANE, your application talks directly to your users.
Imagine even more interactive services
This extension does not use the online service and work offline using the TTS engine (text to speech) of the device.
In a few lines of code, ezSpeech ANE will give voice to your games or applications.
How to test ezSpeech ANE
First, you need to download or fork ezSpeech AIR Native Extension project on GitHub.
Link the extension with your project
The ANE library (ezSpeech.ane) is located in the ‘bin’ folder.
You should add it to your application project’s build path and make sure to package it with your app.
For more information about this process, see :
- How to use ANE with Adobe Flash Builder 4.7
- How to use ANE with Adobe Flash CS6
- How to use ANE with Adobe Flash CC
- How to use ANE with Adobe Animate CC
- How to use ANE with IntelliJ IDEA
- Under File > Project Structure… > Modules make sure you have one module for each of your target platforms
- Under File > Project Structure… > General make sure your project type is ActionScript (or Flex) for AIR mobile platform. You can use
Change..
to have the correct type. - Each module should target either Android or iOS
- Depending on your target, add the correct ANE in the
Dependencies
tab by using + > New Library… - On each of the platform tags you can generate a custom app descriptor or use the IDE generated one. You can use one for all platforms, or create one for each platform.
- Only the generated one will include the extension IDs automatically
- The application descriptor already contains the Android manifest and/or the iOS plist inside. You can set it up exactly like for the Flash Builder when using the custom app descriptor.
- If you use the custom app descriptor, check that the right extension ID is added under
<extensions>
In your application-app.xml file, you need to add the following lines :
1 2 3 |
<extensions> <extensionID>com.fabricemontfort.air.ezSpeech</extensionID> </extensions> |
And in the iPhone InfoAdditions section, add the following lines :
1 2 |
<key>MinimumOSVersion</key> <string>8.0</string> |
Type a few lines of code
Now you’ll know what easy means.
Import, instanciate, test and start to use. Everything is done in 7 lines of code!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import com.fabricemontfort.air.ezSpeech; import com.fabricemontfort.air.ezspeech.languages; var tts:ezSpeech = ezSpeech.instance; if (tts.isSupported()) { tts.setSpeed(0.5); tts.setLanguage(languages.US); tts.say("Hello. This is a sample application to demonstrate the power of speech synthesis. You'll like this!"); tts.setLanguage(languages.FR); tts.say("Bonjour. Ceci est un example d'application pour démontrer la puissance de la synthèse vocale. Vous allez adorer !"); tts.forceLanguage("he"); tts.say("היי. זהו יישום מדגם כדי להדגים את יכולת הדיבור. אני מקווה שאתה נהנה!"); } |
With the setLanguage function :
On Android, if a specific TTS voice file is not installed and internet connection is available, ezSpeech ANE will download and install it automatically.
On iOS, all voices supported by this extension are pre-installed.
On both systems, this ANE supports: English, French, Italian, Spanish, Deutsch, Chinese, Japanese, Russian, Korean, Portuguese, Czech, Dutch, Polish, Swedish, Turkish (the exact same languages than AIR 24 Runtime)
With the forceLanguage function :
On both systems, you have to ensure a proper TTS engine is installed and selected by default to enforce a specific language. This function is EXPERIMENTAL.
Minimum OS version
In order to work, the device operating system must be at least:
- Android 5.0
- iOS 9.0
If device operating system doesn’t match the minimum requierements, “isSupported” method will always return false.
Sample app
There is a complete Flex 4.15 & AIR 22 sample project in the ‘example’ folder. It was created with Flash Builder 4.7.
Feel free to test it and adapt it for your own needs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="application1_creationCompleteHandler(event)"> <s:layout> <s:VerticalLayout gap="10" padding="20"/> </s:layout> <fx:Script> <![CDATA[ import com.fabricemontfort.air.ezSpeech; import com.fabricemontfort.air.ezspeech.events; import com.fabricemontfort.air.ezspeech.languages; import mx.events.FlexEvent; private var tts:ezSpeech; [Bindable] private var tts_speed:Number = 0.54; [Bindable] private var tts_pitch:Number = 1; [Bindable] private var ezspeech_state:String = "NOT TALKING"; protected function application1_creationCompleteHandler(event:FlexEvent):void { this.tts = ezSpeech.instance; this.tts.debug = true; if (this.tts.isSupported()) { this.tts.addEventListener(events.START, onUtteranceStart); this.tts.addEventListener(events.DONE, onUtteranceDone); this.tts.addEventListener(events.ERROR, onUtteranceError); this.tts.addEventListener(events.INITIALIZED, onTTSInitialized); this.tts.addEventListener(events.NOT_INITIALIZED, onTTSNotInitialized); } return; } protected function frButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.FR); if (this.tts.isSupported()){ this.tts.say("Salut. Ceci est un exemple d'application pour démontrer la puissance de la parole. J'espère que vous aimerez !"); } return; } protected function enButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.US); if (this.tts.isSupported()){ this.tts.say("Hello. This is a sample application to demonstrate the power of the speech. I hope that you'll like it!"); } return; } protected function deButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.DE); if (this.tts.isSupported()){ this.tts.say("Hallo. Dies ist eine Beispielanwendung, die Macht der Sprache zu demonstrieren. Ich hoffe, dass Sie es finden mögen!"); } return; } protected function esButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.ES); if (this.tts.isSupported()){ this.tts.say("Hola. Esta es una aplicación de ejemplo para demostrar el poder del discurso. Espero que te guste!"); } return; } protected function itButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.IT); if (this.tts.isSupported()){ this.tts.say("Ciao. Questa è un'applicazione di esempio per dimostrare il potere del discorso. Spero che vi piacerà!"); } return; } protected function zhButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.ZH); if (this.tts.isSupported()){ this.tts.say("你好。这是一个示例应用程序来演示说话的能力。我希望你会喜欢它!"); } return; } protected function jaButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.JA); if (this.tts.isSupported()){ this.tts.say("こんにちは。これは、音声のパワーを実証するサンプル・アプリケーションです。私はあなたがそれを好むだろうことを願っています!"); } return; } protected function ruButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.RU); if (this.tts.isSupported()){ this.tts.say("Здравствуйте. Это пример приложения, чтобы продемонстрировать силу речи. Я надеюсь, что вам понравится!"); } return; } protected function koButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.KO); if (this.tts.isSupported()){ this.tts.say("여보세요. 이 연설의 힘을 보여주는 샘플 응용 프로그램입니다. 나는 당신이 그것을 좋아합니다 희망!"); } return; } protected function ptButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.PT); if (this.tts.isSupported()){ this.tts.say("Olá. Esta é uma aplicação de exemplo para demonstrar o poder do discurso. Eu espero que você vai gostar!"); } return; } protected function csButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.CS); if (this.tts.isSupported()){ this.tts.say("Ahoj. Toto je vzorová aplikace demonstrovat sílu projevu. Doufám, že se vám bude líbit!"); } return; } protected function nlButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.NL); if (this.tts.isSupported()){ this.tts.say("Hallo. Dit is een voorbeeld applicatie om de kracht van de toespraak aan te tonen. Ik hoop dat het je bevalt!"); } return; } protected function plButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.PL); if (this.tts.isSupported()){ this.tts.say("Cześć. To jest przykładowa aplikacja zademonstrować potęgę mowy. Mam nadzieję, że Ci się spodoba!"); } return; } protected function svButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.SV); if (this.tts.isSupported()){ this.tts.say("Hallå. Detta är en exempelprogrammet för att demonstrera kraften i tal. Jag hoppas att du kommer att gilla det!"); } return; } protected function trButton_clickHandler(event:MouseEvent) : void { this.tts.setLanguage(languages.TR); if (this.tts.isSupported()){ this.tts.say("Merhaba. Bu konuşma gücünü göstermek için örnek bir uygulamadır. Ben bunu gibi olacak umuyoruz!"); } return; } // Working on Android natively not iOS protected function heButton_clickHandler(event:MouseEvent) : void { this.tts.forceLanguage("bn_BD"); if (this.tts.isSupported()){ this.tts.say("হাই. এই বাক শক্তি প্রদর্শন করার জন্য একটি নমুনা অ্যাপ্লিকেশন. আমি আশা করি আপনি ভোগ!"); } return; } // Working on both systems protected function daButton_clickHandler(event:MouseEvent) : void { this.tts.forceLanguage("da_DK"); if (this.tts.isSupported()){ this.tts.say("Hej. Dette er en prøve, for at påvise talens. Jeg håber du nyder!"); } return; } // Working on iOS natively and Android with a specific TTS engine protected function arButton_clickHandler(event:MouseEvent) : void { this.tts.forceLanguage("ar"); if (this.tts.isSupported()){ this.tts.say("سلام. هذا هو تطبيق عينة لإثبات القدرة على الكلام. وآمل أن تستمتع!"); } return; } // Working on iOS natively and Android with a specific TTS engine protected function iwButton_clickHandler(event:MouseEvent) : void { this.tts.forceLanguage("he"); if (this.tts.isSupported()){ this.tts.say("היי. זהו יישום מדגם כדי להדגים את יכולת הדיבור. אני מקווה שאתה נהנה!"); } return; } // Working on Android natively protected function swButton_clickHandler(event:MouseEvent) : void { this.tts.forceLanguage("sw"); if (this.tts.isSupported()){ this.tts.say("Hi. Hii ni maombi ya sampuli kuonyesha nguvu ya hotuba. Natumaini kufurahia!"); } return; } // MAKE YOUR OWN TESTS protected function isSpeakingButton_clickHandler(event:MouseEvent):void { trace ("TALKING : " + tts.isSpeaking()); } protected function slowButton_clickHandler(event:MouseEvent):void { this.tts_speed = this.tts_speed - 0.01; if (this.tts.isSupported()){ this.tts.setSpeed(Number(this.tts_speed.toFixed(2))); } return; } protected function fastButton_clickHandler(event:MouseEvent):void { this.tts_speed = this.tts_speed + 0.01; if (this.tts.isSupported()){ this.tts.setSpeed(Number(this.tts_speed.toFixed(2))); } return; } protected function stopButton_clickHandler(event:MouseEvent):void { if (this.tts.isSupported()) { tts.stop(); } } protected function onUtteranceStart(event:Event):void { ezspeech_state = "TALKING"; } protected function onUtteranceDone(event:Event):void { ezspeech_state = "NOT TALKING"; } protected function onUtteranceError(event:Event):void { trace ("Unknown error with Utterance"); } protected function onTTSInitialized(event:Event):void { if (tts.isSupported()) { this.tts.setSpeed(Number(this.tts_speed.toFixed(2))); this.tts.setPitch(Number(this.tts_pitch.toFixed(2))); this.tts.setLanguage(languages.US); this.tts.say("Let's go"); } } protected function onTTSNotInitialized(event:Event):void { trace ("This device does not support TTS. An unknown error occured during initialization"); } protected function deepButton_clickHandler(event:MouseEvent):void { this.tts_pitch = this.tts_pitch - 0.01; if (this.tts.isSupported()){ this.tts.setPitch(Number(this.tts_pitch.toFixed(2))); } return; } protected function acuteButton_clickHandler(event:MouseEvent):void { this.tts_pitch = this.tts_pitch + 0.01; if (this.tts.isSupported()){ this.tts.setPitch(Number(this.tts_pitch.toFixed(2))); } return; } ]]> </fx:Script> <s:Label width="100%" text="ezSpeech Demo" textAlign="center" typographicCase="uppercase" fontWeight="bold" paddingBottom="10" paddingTop="10"/> <s:Button id="isSpeakingButton" label="? Talking ?" width="100%" click="isSpeakingButton_clickHandler(event)"/> <s:Button id="stopButton" label="STOP UTTERANCE" width="100%" click="stopButton_clickHandler(event)"/> <s:Label text="SPEED" width="100%" textAlign="center" paddingBottom="0" paddingTop="10"/> <s:HGroup gap="10" width="100%" padding="10" verticalAlign="middle"> <s:Button id="slowButton" label="- 0.01 -" width="30%" click="slowButton_clickHandler(event)"/> <s:Label text="{tts_speed}" width="40%" textAlign="center"/> <s:Button id="fastButton" label="+ 0.01 +" width="30%" click="fastButton_clickHandler(event)"/> </s:HGroup> <s:Label text="PITCH" width="100%" textAlign="center" paddingBottom="0" paddingTop="10"/> <s:HGroup gap="10" width="100%" padding="10" verticalAlign="middle"> <s:Button id="deepButton" label="- 0.01 -" width="30%" click="deepButton_clickHandler(event)"/> <s:Label text="{tts_pitch}" width="40%" textAlign="center"/> <s:Button id="acuteButton" label="+ 0.01 +" width="30%" click="acuteButton_clickHandler(event)"/> </s:HGroup> <s:Label text="{ezspeech_state}" width="100%" textAlign="center" paddingBottom="10" paddingTop="10"/> <s:Scroller width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="auto"> <s:VGroup gap="10" padding="10"> <s:Button id="frButton" width="100%" label="French" click="frButton_clickHandler(event)"/> <s:Button id="enButton" width="100%" label="English" click="enButton_clickHandler(event)"/> <s:Button id="deButton" width="100%" label="German" click="deButton_clickHandler(event)"/> <s:Button id="esButton" width="100%" label="Spanish" click="esButton_clickHandler(event)"/> <s:Button id="itButton" width="100%" label="Italian" click="itButton_clickHandler(event)"/> <s:Button id="zhButton" width="100%" label="Chinese" click="zhButton_clickHandler(event)"/> <s:Button id="jaButton" width="100%" label="Japanese" click="jaButton_clickHandler(event)"/> <s:Button id="ruButton" width="100%" label="Russian" click="ruButton_clickHandler(event)"/> <s:Button id="koButton" width="100%" label="Korean" click="koButton_clickHandler(event)"/> <s:Button id="ptButton" width="100%" label="Portuguese" click="ptButton_clickHandler(event)"/> <s:Button id="csButton" width="100%" label="Czech" click="csButton_clickHandler(event)"/> <s:Button id="nlButton" width="100%" label="Dutch" click="nlButton_clickHandler(event)"/> <s:Button id="plButton" width="100%" label="Polish" click="plButton_clickHandler(event)"/> <s:Button id="svButton" width="100%" label="Swedish" click="svButton_clickHandler(event)"/> <s:Button id="trButton" width="100%" label="Turkish" click="trButton_clickHandler(event)"/> <s:Button id="heButton" width="100%" label="Bengali (Experimental)" click="heButton_clickHandler(event)"/> <s:Button id="daButton" width="100%" label="Danish (Experimental)" click="daButton_clickHandler(event)"/> <s:Button id="arButton" width="100%" label="Arabic (Experimental)" click="arButton_clickHandler(event)"/> <s:Button id="iwButton" width="100%" label="Hebrew (Experimental)" click="iwButton_clickHandler(event)"/> <s:Button id="swButton" width="100%" label="Swahili (Experimental)" click="swButton_clickHandler(event)"/> </s:VGroup> </s:Scroller> </s:Application> |
Documentation
You can access the complete asdoc in the ‘doc’ folder.
Author
ezSpeech ANE is developped by Fabrice Montfort. All rights are reserved.
Showcase
This ANE is used in my “Anagrams Free” application available on Android and iOS mobile devices. Feel free to download it.
Buy a licence
If you want to use in a production project, you have to purchase the full version.
You will be able to download an archive with the full production version from your account on this website after your payment has been validated.
This is an ANNUAL LICENSE, valid for all your projects. You will benefit from all updates without restrictions during 365 days after your purchase. After that delay, you’ll have to buy a new license.
Support
If you have any question, comment, or suggestion, you can leave me a message on Github. I’ll give you a quick answer.
I made the choice to centralize all trade questions and answers on GitHub so that they can serve all users.
Updates
1.5.0 – Working with AIR 33 and iOS 13. 32bit and 64bit support for iOS and Android. And it now works perfectly well in Android and iOS simulators (from Android Studio and Xcode)
1.2.0 – Working with AIR 30 and iOS 11.3. Bug resolved on AIR Simulator on Desktop
1.0.9 – Working better with ezSTT
1.0.8 – Adding setPitch and forceLanguage functions
1.0.5 – Adding TTS Events : INITIALIZED, NOT_INITIALIZED and stop() method
1.0.4 – Adding Utterance Events : START, DONE, ERROR
1.0.3 – Adding isSpeaking function to let you know if TTS is talking or not
1.0.1 – Adding languages : Chinese, Japanese, Russian, Korean, Portuguese, Czech, Dutch, Polish, Swedish, Turkish
1.0.0 – First public release