private Prompt createDefaultStartPrompt() { if (this._speechKit != null) { int beepResId = _context .getResources() .getIdentifier("rawbeep", "raw", _context.getApplicationInfo().packageName); return _speechKit.defineAudioPrompt(beepResId); } else { Log.e( PLUGIN_NAME, "Cannot create Start Prompt: SpeechKit not initialized, returning default prompt [NONE]..."); } return null; }
public void initializeResources() { if (_speechKit != null) { return; } _speechKit = SpeechKit.initialize( _context, Credentials.getSpeechKitAppId(), Credentials.getSpeechKitServer(), Credentials.getSpeechKitPort(), // the port number, e.g. 443, Credentials.getSpeechKitSsl(), // true if SSL should be used, Credentials .getSpeechKitCertSummary(), // the summary String (must match the Common Name (CN) // of the used certificate-data; as provided by Nuance) Credentials.getSpeechKitCertData(), // the certificate data, Credentials.getSpeechKitAppKey()); _speechKit.connect(); int beepResId = _context .getResources() .getIdentifier("rawbeep", "raw", _context.getApplicationInfo().packageName); // TODO: Keep an eye out for audio prompts not-working on the Android 2 or other 2.2 devices. this._defaultStartPrompt = _speechKit.defineAudioPrompt(beepResId); this._defaultStopPrompt = Prompt.vibration(100); _speechKit.setDefaultRecognizerPrompts( this._defaultStartPrompt, this._defaultStopPrompt, null, null); // Create Vocalizer listener Vocalizer.Listener vocalizerListener = new Vocalizer.Listener() { @Override public void onSpeakingBegin(Vocalizer vocalizer, String text, Object context) { Log.d(PLUGIN_TTS_NAME, String.format("start speaking: '%s'", text)); if (context instanceof Vocalizer.Listener) { ((Vocalizer.Listener) context).onSpeakingBegin(vocalizer, text, null); } } @Override public void onSpeakingDone( Vocalizer vocalizer, String text, SpeechError error, Object context) { // Use the context to determine if this was the final TTS phrase Log.d(PLUGIN_TTS_NAME, String.format("speaking done: '%s'", text)); if (context instanceof Vocalizer.Listener) { ((Vocalizer.Listener) context).onSpeakingDone(vocalizer, text, error, null); } } }; // Create a single Vocalizer here. _vocalizer = _speechKit.createVocalizerWithLanguage(_currentLanguage, vocalizerListener, new Handler()); _recognitionListener = createRecognitionListener(); _handler = new Handler(); }