当前位置: 首页>>代码示例>>Java>>正文


Java Assets类代码示例

本文整理汇总了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();
}
 
开发者ID:kevalpatel2106,项目名称:robo-car,代码行数:26,代码来源:PocketSphinx.java

示例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();
}
 
开发者ID:Mighty-Beards,项目名称:Flyting,代码行数:24,代码来源:FlyteToText.java

示例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());
    }

}
 
开发者ID:alinekborges,项目名称:SmartChair,代码行数:18,代码来源:MainFragment.java

示例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);
}
 
开发者ID:NielsMasdorp,项目名称:Speculum-Android,代码行数:18,代码来源:MainInteractorImpl.java

示例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();
    }
}
 
开发者ID:icaksama,项目名称:RapidSphinx,代码行数:10,代码来源:RapidSphinx.java

示例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();
}
 
开发者ID:Nilhcem,项目名称:audiofun-androidthings,代码行数:28,代码来源:PocketSphinx.java

示例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();
}
 
开发者ID:panda919,项目名称:VoiceRecognition-android-demo-Panda,代码行数:28,代码来源:PocketSphinxActivity.java

示例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();
}
 
开发者ID:hypeapps,项目名称:black-mirror,代码行数:31,代码来源:PocketSphinx.java

示例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();
}
 
开发者ID:tharvey,项目名称:BlocklyBot,代码行数:36,代码来源:Listen.java

示例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);
}
 
开发者ID:leouo,项目名称:lumos-android,代码行数:12,代码来源:VoiceRecognizer.java

示例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());
//        }
    }
 
开发者ID:dimixar,项目名称:unity3DPocketSphinx-android-lib,代码行数:39,代码来源:PocketSphinxActivity.java

示例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");
    }
}
 
开发者ID:alinekborges,项目名称:SmartChair,代码行数:12,代码来源:MainFragment.java

示例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();
}
 
开发者ID:alinekborges,项目名称:SmartChair,代码行数:43,代码来源:PocketSphinxActivity.java

示例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();
	}
 
开发者ID:harshadura,项目名称:CheesyCam,代码行数:79,代码来源:MainActivity.java


注:本文中的edu.cmu.pocketsphinx.Assets类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。