本文整理汇总了Java中edu.cmu.pocketsphinx.Assets类的典型用法代码示例。如果您正苦于以下问题:Java Assets类的具体用法?Java Assets怎么用?Java Assets使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Assets类属于edu.cmu.pocketsphinx包,在下文中一共展示了Assets类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runRecognizerSetup
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
private void runRecognizerSetup(final Context context) {
// Recognizer initialization is a time-consuming and it involves IO, so we execute it in async task
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(context);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
Log.e(TAG, "Failed to initialize recognizer: " + result);
} else {
listener.onSpeechRecognizerReady();
}
}
}.execute();
}
示例2: FlyteToText
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
public FlyteToText(final Context context, final RecognitionListener listener) {
// Start recognizer in a syncTask to avoid freeze
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(context);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir, listener);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
Log.e("Sphinx error", result.getMessage());
}
}
}.execute();
}
示例3: setUpSpeechRegonition
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
@Background
public void setUpSpeechRegonition() {
//txtCaptionText.setText("Preparing the recognizer");
try {
Assets assets = new Assets(getActivity());
File assetDir = assets.syncAssets();
Log.i(LOG_TAG, assetDir.getAbsolutePath());
setupRecognizer(assetDir);
switchSearch(KWS_SEARCH);
//String caption = getResources().getString(captions.get(MENU_SEARCH));
//txtCaptionText.setText(caption);
} catch (Exception e) {
Log.i(LOG_TAG, "ERRO");
//txtCaptionText.setText("Failed to init recognizer " + e.getMessage());
}
}
示例4: getAssetsDirForSpeechRecognizer
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
@Override
public void getAssetsDirForSpeechRecognizer(Subscriber<File> subscriber) {
Observable.defer(() -> {
try {
Assets assets = new Assets(application);
File assetDir = assets.syncAssets();
return Observable.just(assetDir);
} catch (IOException e) {
throw new RuntimeException("IOException: " + e.getLocalizedMessage());
}
})
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(subscriber);
}
示例5: RapidSphinx
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
public RapidSphinx(Context context) {
this.context = context;
try {
Assets assetsContext = new Assets(context);
assetDir = assetsContext.syncAssets();
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: runRecognizerSetup
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
private void runRecognizerSetup(final Context context) {
Log.d(TAG, "Recognizer setup");
// Recognizer initialization is a time-consuming and it involves IO, so we execute it in async task
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(context);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
Log.e(TAG, "Failed to initialize recognizer: " + result);
} else {
listener.onSpeechRecognizerReady();
}
}
}.execute();
}
示例7: runRecognizerSetup
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
private void runRecognizerSetup() {
// Recognizer initialization is a time-consuming and it involves IO,
// so we execute it in async task
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(PocketSphinxActivity.this);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
((TextView) findViewById(R.id.caption_text))
.setText("Failed to init recognizer " + result);
} else {
switchSearch(KWS_SEARCH);
}
}
}.execute();
}
示例8: runRecognizerSetup
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
/**
* @param context potrzebny dla Assets
* Konfiguruje obiekt rozpoznawania mowy. Odczytuje model z plików.
*/
private void runRecognizerSetup(final Context context) {
Log.d(TAG, "Recognizer setup");
// Recognizer initialization is a time-consuming and it involves IO, so we execute it in async task
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(context);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
Log.e(TAG, "Failed to initialize recognizer: " + result);
} else {
activationKeywordListener.onActivationKeywordRecognizerReady();
}
}
}.execute();
}
示例9: Listen
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
public Listen(Activity activity, final List<String> phrases, IEventListener callback) {
mActivity = activity;
mEventListener = callback;
mSetup = false;
mListening = false;
// Recognizer initialization is a time-consuming and it involves IO,
// so we execute it in async task
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(mActivity);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir, phrases);
} catch (IOException e) {
Log.e(TAG, "Error setting up recognizer:" + e);
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
Log.i(TAG, "onPostExecute:" + result);
if (result != null) {
Log.e(TAG, "Failed to init recognizer " + result);
} else {
Log.i(TAG, "Setup ok - initializing search");
mListening = true;
mRecognizer.startListening("robot");
}
}
}.execute();
}
示例10: startListener
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
public void startListener(){
try {
Assets assets = new Assets(context);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
} catch (IOException e) {
Toast.makeText(context.getApplicationContext(), context.getResources().getString(R.string.error_start_recognizer), Toast.LENGTH_LONG).show();
}
recognizer.startListening(COMMANDS_SEARCH);
}
示例11: RunRecognizerSetup
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
public void RunRecognizerSetup() {
// Recognizer initialization is a time-consuming and it involves IO,
// so we execute it in async task
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(activityContext);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
UnityPlayer.UnitySendMessage(CUnityGameObjName, COnInitializeFailed, result.getMessage());
} else {
UnityPlayer.UnitySendMessage(CUnityGameObjName, COnInitializeSucces, "Initialized with succces.");
}
}
}.execute();
// try
// {
// Assets assets = new Assets(activityContext);
// File assetDir = assets.syncAssets();
// setupRecognizer(assetDir);
// UnityPlayer.UnitySendMessage(CUnityGameObjName, COnInitializeSucces, "Initialized with succces.");
// }
// catch (Exception result)
// {
// UnityPlayer.UnitySendMessage(CUnityGameObjName, COnInitializeFailed, result.getMessage());
// }
}
示例12: setUpSpeechRegonition
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
@Background
public void setUpSpeechRegonition() {
try {
Assets assets = new Assets(getActivity());
File assetDir = assets.syncAssets();
Log.i(LOG_TAG, assetDir.getAbsolutePath());
setupRecognizer(assetDir);
} catch (Exception e) {
Log.i(LOG_TAG, "ERRO");
}
}
示例13: onCreate
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
// Prepare the data for UI
captions = new HashMap<String, Integer>();
captions.put(KWS_SEARCH, R.string.kws_caption);
captions.put(MENU_SEARCH, R.string.menu_caption);
captions.put(DIGITS_SEARCH, R.string.digits_caption);
captions.put(PHONE_SEARCH, R.string.phone_caption);
captions.put(FORECAST_SEARCH, R.string.forecast_caption);
setContentView(R.layout.main);
((TextView) findViewById(R.id.caption_text))
.setText("Preparing the recognizer");
// Recognizer initialization is a time-consuming and it involves IO,
// so we execute it in async task
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(PocketSphinxActivity.this);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
((TextView) findViewById(R.id.caption_text))
.setText("Failed to init recognizer " + result);
} else {
switchSearch(KWS_SEARCH);
}
}
}.execute();
}
示例14: onCreate
import edu.cmu.pocketsphinx.Assets; //导入依赖的package包/类
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
// Prepare the data for UI
captions = new HashMap<String, Integer>();
captions.put(KWS_SEARCH, R.string.kws_caption);
captions.put(MENU_SEARCH, R.string.menu_caption);
captions.put(DIGITS_SEARCH, R.string.digits_caption);
captions.put(FORECAST_SEARCH, R.string.forecast_caption);
setContentView(R.layout.main);
((TextView) findViewById(R.id.caption_text))
.setText("Preparing the voice recognizer, Please wait a moment ..");
L1 = (LinearLayout) findViewById(R.id.main_lay);
makeText(getApplicationContext(), "Loading .. Please wait .. ", Toast.LENGTH_LONG).show();
File folder = new File(Environment.getExternalStorageDirectory() + "/CheesyCam");
allFiles = folder.list();
SCAN_PATH=Environment.getExternalStorageDirectory().toString()+"/CheesyCam/"+allFiles[0];
// AdView adView = (AdView) this.findViewById(R.id.adView);
// AdRequest adRequest = new AdRequest.Builder().build();
// adView.loadAd(adRequest);
// mCamera = getCameraInstance();
/*
* mCameraPreview = new CameraPreview(this, mCamera); FrameLayout
* preview = (FrameLayout) findViewById(R.id.camera_preview);
* preview.addView(mCameraPreview);
*/
// mCamera.takePicture(null, null, mPicture);
// Recognizer initialization is a time-consuming and it involves IO,
// so we execute it in async task
preview = new Preview(this,
(SurfaceView) findViewById(R.id.surfaceView));
preview.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
((FrameLayout) findViewById(R.id.preview)).addView(preview);
preview.setKeepScreenOn(true);
// buttonClick = (Button) findViewById(R.id.buttonClick);
//
// buttonClick.setOnClickListener(new OnClickListener() {
// public void onClick(View v) {
// // preview.camera.takePicture(shutterCallback, rawCallback,
// jpegCallback);
// camera.takePicture(shutterCallback, rawCallback, jpegCallback);
// }
// });
new AsyncTask<Void, Void, Exception>() {
@Override
protected Exception doInBackground(Void... params) {
try {
Assets assets = new Assets(MainActivity.this);
File assetDir = assets.syncAssets();
setupRecognizer(assetDir);
} catch (IOException e) {
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception result) {
if (result != null) {
((TextView) findViewById(R.id.caption_text))
.setText("Failed to init recognizer " + result);
} else {
switchSearch(KWS_SEARCH);
}
}
}.execute();
}