这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/src/main/java/com/termux/api/apis/SpeechToTextAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

import java.io.PrintWriter;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.LinkedBlockingQueue;

public class SpeechToTextAPI {

private static final String LOG_TAG = "SpeechToTextAPI";
private static String language;

public static class SpeechToTextService extends IntentService {

Expand Down Expand Up @@ -145,7 +147,7 @@ public void onBeginningOfSpeech() {
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Enter shell command");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
mSpeechRecognizer.startListening(recognizerIntent);
}
Expand Down Expand Up @@ -182,6 +184,16 @@ public void writeResult(PrintWriter out) throws Exception {
public static void onReceive(final Context context, Intent intent) {
Logger.logDebug(LOG_TAG, "onReceive");

if (intent.hasExtra("language")) {
language = intent.getStringExtra("language");
//Toast.makeText(context,"using language [from parameter]: " + language, Toast.LENGTH_SHORT).show();
Logger.logDebug(LOG_TAG, "using language [from parameter]: " + language);
} else {
language = String.valueOf(Locale.getDefault());
//Toast.makeText(context,"using language [from locale default]: " + language, Toast.LENGTH_SHORT).show();
Logger.logDebug(LOG_TAG, "using language [from locale default]: " + language);
}

context.startService(new Intent(context, SpeechToTextService.class).putExtras(intent.getExtras()));
}

Expand Down