开源的语音识别+TTS for iPhone(三)Configuring Your App For OpenEars

Configuring Your App For OpenEars

Conventions used in these instructions:

[OPENEARS] will be used to mean the path on your system to the OpenEars distribution folder after you downloaded and unzipped it. So, if you downloaded it to your Documents folder and your username is “username”, [OPENEARS] means:

/Users/username/Documents/OpenEars

Whenever you are asked to add something to your project , this means very specifically that with your Xcode project open and in the foreground (your app project, not either of the projects that ship with OpenEars), go to the Xcode menubar and select File->Add files to (your project name), or press command-option-a.  After you do this, you will always be shown the following window and you should always use the following settings for it:

OpenEars Installation File Reference Settings
What we’ll be doing:

Preparing your project to be able to use OpenEars by adding the files that the app needs, the header search paths, the frameworks, and the actual OpenEars library.

Step 1: using the [OPENEARS] folder that you successfully ran the sample app from in Getting Started With Openears, drag that [OPENEARS] folder into the root folder of your new app project, so that the project file for your app is at the same folder level as the OpenEars folder:

OpenEars Folder

Next, add the following files to your app project (see “Conventions used in these instructions” above for the specifics of adding things to your project):

[OPENEARS]/OpenEarsLibrary/OpenEarsLibrary.xcodeproj
[OPENEARS]/OpenEarsLibrary/Classes/include/OpenEarsConfig.h
[OPENEARS]/CMULibraries/flite-1.4-release/include/OpenEarsVoiceConfig.h
[OPENEARS]/CMULibraries/pocketsphinx-0.6.1/model/lm/en_US/cmu07a.dic

And add the following folder to your project (make sure you add the entire folder, not its individual contents):

[OPENEARS]/CMULibraries/pocketsphinx-0.6.1/model/hmm/en_US/hub4wsj_sc_8k

Step 2: From Xcode, select your blue project icon for your app (not the OpenEarsLibrary project) in the Project Navigator and select its target under the TARGETS header in the left-hand column in the editor. Navigate to the tab Build Phases. Click “Target Dependencies”.

OpenEars Folder

Click the plus button for Target Dependencies. Then select the gray OpenEarsLibrary icon in that dialog and click “Add”.

OpenEars Folder

Step 3: In the same view, with the app target still selected underneath the header TARGETS in the left-hand pane of the editor window, navigate to the Build Phases pane and select “Link Binary With Libraries”.

OpenEars Folder

Tapping the plus button, add the OpenEars framework libOpenEarsLibrary.a found in a folder at the top called workspace:

OpenEars Folder

And also add the following iOS frameworks that are found in the same dialog:

AudioToolbox.framework
AVFoundation.framework
libiconv.2.4.0.dylib

Apple has informed me that it is fine to link to libiconv.2.4.0.dylib because its headers are public.

Step 4: In the same view, select your blue project icon in the left-hand editor pane under the header PROJECT and navigate to the tab “Build Settings”. Search for the build setting called Header Search Paths.

OpenEars Folder

Under the column with the name of your app (as opposed to Resolved or iOS Default), double-click the Header Search Paths setting field and then click the plus button to add each of the following header search paths to your app:

OpenEars/CMULibraries/flite-1.4-release/include
OpenEars/CMULibraries/pocketsphinx-0.6.1/include
OpenEars/CMULibraries/sphinxbase-0.6.1/include
OpenEars/OpenEarsLibrary/Classes/include

None of them should have the “Recursive” checkbox checked.

OpenEars Folder

Step 6: While you are in the same view, search for the build setting “Compile for Thumb” and set it to “no”.

OpenEars Folder

Step 6: Any class in which you intend to host PocketsphinxController and/or LanguageModelGenerator must have its suffix .m changed to .mm. So, if it is called MyClass.m you will need to rename it to MyClass.mm or you will get errors.

Step 7: In this class that you just renamed to mm, test whether your app is correctly configured for OpenEars by adding the lines:

#import "AudioSessionManager.h"
#import "PocketsphinxController.h"
#import "FliteController.h"
#import "OpenEarsEventsObserver.h"
#import "LanguageModelGenerator.h"

and then put the following methods anywhere (for testing purposes only, this is not the correct use of these classes at all), for example in viewDidLoad:

AudioSessionManager *audioSessionManager = [[AudioSessionManager alloc]init];
[audioSessionManager release];
PocketsphinxController *pocketsphinxController = [[PocketsphinxController alloc]init];
[pocketsphinxController release];
FliteController *fliteController = [[FliteController alloc]init];
[fliteController release];
LanguageModelGenerator *languageModelGenerator = [[LanguageModelGenerator alloc]init];
[languageModelGenerator release];

If the app can build and run, it is configured correctly to be able to use all the features of OpenEars and you’re done. Remove the test methods from the previous step since they will only cause confusion later if you leave them there, and continue on to “Using OpenEars in your app”.

If you can’t build and run, go carefully through the steps listed above again, making sure that the OpenEars folder is in the right location in your app project folder and that you haven’t made any typos in the Search Header entries or overlooked other small details.

If you continue to have issues, check out the FAQ/Support page , and if everything is working for you, congrats! Continue on to “Using OpenEars In Your App “.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值