Skip to content

Instantly share code, notes, and snippets.

@creativetechnologist
Created July 19, 2012 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save creativetechnologist/3143981 to your computer and use it in GitHub Desktop.
Save creativetechnologist/3143981 to your computer and use it in GitHub Desktop.
Integrating RubyMotion and the iSpeech SDK
As of 19th July 2012, RubyMotion has a couple of issues with external libraries as I discovered when trying the integration, thanks to Laurent, the architect of RubyMotion and with some prompting from Stéphane Wirtel here is the issue and resolution including the code to make the iPhone speak.
Firstly setting up the app, assuming you've already copied the files you need into your vendor/iSpeechSDK directory this is the code needed in the rakefile as per any normal library ...
app.vendor_project('vendor/iSpeechSDK', :static,
:products => ["libiSpeechSDK.a"],
:headers_dir => "Headers")
However, the bundle file which should be in the directory won't be picked up by RubyMotion which doesn't become apparent until you try and instantiate the object, to avoid this issue move the file iSpeechSDK.bundle into the /resources directory on the project root.
The second problem is that the iSpeechSDK class name starts with a lower-case letter, which is not a valid constant name in Ruby, this won't work ...
@sdk = iSpeechSDK.sharedSDK
Instead do this ...
@sdk = NSClassFromString('iSpeechSDK').sharedSDK
So, that issue is solved, if you paste the following code into your app_delegate then you'll hear some speech
@sdk = NSClassFromString('iSpeechSDK').sharedSDK
@sdk.APIKey = "<your api key>"
@speach = NSClassFromString('ISSpeechSynthesis').alloc.initWithText("Hello World")
errorPointer = Pointer.new(:object)
@speach.speak(errorPointer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment