本文整理汇总了Java中ee.ioc.phon.android.speechutils.Log类的典型用法代码示例。如果您正苦于以下问题:Java Log类的具体用法?Java Log怎么用?Java Log使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Log类属于ee.ioc.phon.android.speechutils包,在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replace
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
@Override
public boolean replace(String str1, String str2) {
boolean success = false;
mInputConnection.beginBatchEdit();
ExtractedText extractedText = mInputConnection.getExtractedText(new ExtractedTextRequest(), 0);
if (extractedText != null) {
CharSequence beforeCursor = extractedText.text;
//CharSequence beforeCursor = mInputConnection.getTextBeforeCursor(MAX_SELECTABLE_CONTEXT, 0);
Log.i("replace: " + beforeCursor);
int index = beforeCursor.toString().lastIndexOf(str1);
Log.i("replace: " + index);
if (index > 0) {
mInputConnection.setSelection(index, index);
mInputConnection.deleteSurroundingText(0, str1.length());
if (!str2.isEmpty()) {
mInputConnection.commitText(str2, 0);
}
success = true;
}
mInputConnection.endBatchEdit();
}
return success;
}
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:24,代码来源:InputConnectionCommandEditor.java
示例2: rewrite
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
/**
* Rewrites and returns the given string,
* and the first matching command.
*/
public Triple rewrite(String str) {
for (Command command : mCommands) {
Log.i("editor: rewrite with command: " + str + ": " + command);
Pair<String, String[]> pair = command.match(str);
if (pair != null) {
str = pair.first;
String commandId = command.getId();
if (commandId != null) {
String[] args = pair.second;
Log.i("editor: rewrite: success: " + str + ": " + commandId + "(" + TextUtils.join(",", args) + ")");
return new Triple(commandId, str, args);
}
}
}
return new Triple(null, str, null);
}
示例3: activity
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
@Override
public Op activity(final String json) {
return new Op("activity") {
@Override
public Op run() {
Op undo = null;
try {
if (IntentUtils.startActivityIfAvailable(mContext, JsonUtils.createIntent(json.replace(F_SELECTION, getSelectedText())))) {
undo = NO_OP;
}
} catch (JSONException e) {
Log.i("startSearchActivity: JSON: " + e.getMessage());
}
return undo;
}
};
}
示例4: getEncoderNamesForType
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
/**
* Maps the given mime type to a list of names of suitable codecs.
* Only OMX-codecs are considered.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static List<String> getEncoderNamesForType(String mime) {
LinkedList<String> names = new LinkedList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
int n = MediaCodecList.getCodecCount();
for (int i = 0; i < n; ++i) {
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
if (!info.isEncoder()) {
continue;
}
if (!info.getName().startsWith("OMX.")) {
// Unfortunately for legacy reasons, "AACEncoder", a
// non OMX component had to be in this list for the video
// editor code to work... but it cannot actually be instantiated
// using MediaCodec.
Log.i("skipping '" + info.getName() + "'.");
continue;
}
String[] supportedTypes = info.getSupportedTypes();
for (int j = 0; j < supportedTypes.length; ++j) {
if (supportedTypes[j].equalsIgnoreCase(mime)) {
names.push(info.getName());
break;
}
}
}
}
// Return an empty list if API is too old
// TODO: maybe return null or throw exception
return names;
}
示例5: showMetrics
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void showMetrics(MediaFormat format, int numBytesSubmitted, int numBytesDequeued) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Log.i("queued a total of " + numBytesSubmitted + " bytes, " + "dequeued " + numBytesDequeued + " bytes.");
int sampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE);
int channelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
int inBitrate = sampleRate * channelCount * 16; // bit/sec
int outBitrate = format.getInteger(MediaFormat.KEY_BIT_RATE);
float desiredRatio = (float) outBitrate / (float) inBitrate;
float actualRatio = (float) numBytesDequeued / (float) numBytesSubmitted;
Log.i("desiredRatio = " + desiredRatio + ", actualRatio = " + actualRatio);
}
}
示例6: showSomeBytes
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
/**
* Just for testing...
*/
public static void showSomeBytes(String tag, byte[] bytes) {
Log.i("enc: " + tag + ": length: " + bytes.length);
String str = "";
int len = bytes.length;
if (len > 0) {
for (int i = 0; i < len && i < 5; i++) {
str += Integer.toHexString(bytes[i]) + " ";
}
Log.i("enc: " + tag + ": hex: " + str);
}
}
示例7: closeQuietly
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
private static void closeQuietly(InputStream is) {
try {
if (is != null) {
is.close();
}
} catch (Exception e) {
Log.i(e.getMessage());
}
}
示例8: startActivityIfAvailable
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
public static boolean startActivityIfAvailable(Context context, Intent... intents) {
PackageManager mgr = context.getPackageManager();
try {
for (Intent intent : intents) {
if (isActivityAvailable(mgr, intent)) {
// TODO: is it sensible to always start activity for result,
// even if the activity is not designed to return a result
if (context instanceof Activity) {
context.startActivity(intent);
} else {
// Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | intent.getFlags());
context.startActivity(intent);
}
//activity.startActivityForResult(intent, 2);
return true;
} else {
Log.i("startActivityIfAvailable: not available: " + intent);
}
}
showMessage(context, R.string.errorFailedLaunchIntent);
} catch (SecurityException e) {
// This happens if the user constructs an intent for which we do not have a
// permission, e.g. the CALL intent.
Log.i("startActivityIfAvailable: " + e.getMessage());
showMessage(context, e.getLocalizedMessage());
}
return false;
}
示例9: launchIfIntent
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
/**
* Rewrites the text. If the result is a command then executes it (only "activity" is currently
* supported). Otherwise returns the rewritten string.
* Errors that occur during the execution of "activity" are communicated via toasts.
* The possible errors are: syntax error in JSON, nobody responded to the intent, no permission to launch
* the intent.
*/
public static String launchIfIntent(Context context, Iterable<UtteranceRewriter> urs, String text) {
String newText = text;
for (UtteranceRewriter ur : urs) {
// Skip null, i.e. a case where a rewrites name did not resolve to a table.
if (ur == null) {
continue;
}
UtteranceRewriter.Rewrite rewrite = ur.getRewrite(newText);
if (rewrite.isCommand() && rewrite.mArgs != null && rewrite.mArgs.length > 0) {
// Commands that interpret their 1st arg as an intent in JSON.
// There can be other commands in the future.
try {
Intent intent = JsonUtils.createIntent(rewrite.mArgs[0]);
switch (rewrite.mId) {
case "activity":
startActivityIfAvailable(context, intent);
break;
case "service":
// TODO
break;
case "broadcast":
// TODO
break;
default:
break;
}
} catch (JSONException e) {
Log.i("launchIfIntent: JSON: " + e.getMessage());
showMessage(context, e.getLocalizedMessage());
}
return null;
}
newText = rewrite.mStr;
}
return newText;
}
示例10: saveWavToFile
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
public static void saveWavToFile(String wavFileFullPath, byte[] wav, boolean append) {
try {
FileUtils.writeByteArrayToFile(new File(wavFileFullPath), wav, append);
}
catch (IOException e) {
Log.e("Could not save a recording to " + wavFileFullPath + " due to: " + e.getMessage());
}
}
示例11: saveWavHeaderToFile
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
public static void saveWavHeaderToFile(String wavFileFullPath, byte[] wavHeader) {
try {
RandomAccessFile file = new RandomAccessFile(wavFileFullPath, "rw");
file.seek(0L);
file.write(wavHeader);
file.close();
}
catch(Throwable t) {
Log.e("Could not write/rewrite the wav header to " + wavFileFullPath + " due to: " + t.getMessage());
}
}
示例12: getEncoderNamesForType
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
/**
* Maps the given mime type to a list of names of suitable codecs.
* Only OMX-codecs are considered.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static List<String> getEncoderNamesForType(String mime) {
LinkedList<String> names = new LinkedList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
int n = MediaCodecList.getCodecCount();
for (int i = 0; i < n; ++i) {
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
if (!info.isEncoder()) {
continue;
}
if (!info.getName().startsWith("OMX.")) {
// Unfortunately for legacy reasons, "AACEncoder", a
// non OMX component had to be in this list for the video
// editor code to work... but it cannot actually be instantiated
// using MediaCodec.
Log.i("skipping '" + info.getName() + "'.");
continue;
}
String[] supportedTypes = info.getSupportedTypes();
for (String type : supportedTypes) {
if (type.equalsIgnoreCase(mime)) {
names.push(info.getName());
break;
}
}
}
}
// Return an empty list if API is too old
// TODO: maybe return null or throw exception
return names;
}
示例13: onCancel
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
/**
* Stops the recording and closes the connection to the server.
*/
@Override
protected void onCancel(RecognitionService.Callback listener) {
Log.i("onCancel");
disconnectAndStopRecording();
// Send empty results if recognition is cancelled
// TEST: if it works with Google Translate and Slide IT
onResults(new Bundle());
}
示例14: createCommandFilter
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
public static CommandMatcher createCommandFilter(final String localeAsStr, final ComponentName serviceComponent, final ComponentName appComponent) {
final String serviceClassName = serviceComponent == null ? null : serviceComponent.getClassName();
// The Kõnele launcher (whose calling activity == null) can be matched using ":".
final String appClassName = appComponent == null ? ":" : appComponent.getClassName();
return new CommandMatcher() {
@Override
public boolean matches(Pattern localePattern, Pattern servicePattern, Pattern appPattern) {
Log.i("matches?: pattern: <" + localePattern + "> <" + servicePattern + "> <" + appPattern + ">");
if (localeAsStr != null && localePattern != null) {
if (!localePattern.matcher(localeAsStr).find()) {
return false;
}
}
if (serviceClassName != null && servicePattern != null) {
if (!servicePattern.matcher(serviceClassName).find()) {
return false;
}
}
if (appClassName != null && appPattern != null) {
if (!appPattern.matcher(appClassName).find()) {
return false;
}
}
Log.i("matches: " + localeAsStr + " " + serviceClassName + " " + appClassName);
return true;
}
};
}
示例15: onStopListening
import ee.ioc.phon.android.speechutils.Log; //导入依赖的package包/类
/**
* Stops the recording and informs the server that no more packages are coming.
*/
@Override
protected void onStopListening(RecognitionService.Callback listener) {
Log.i("onStopListening");
onEndOfSpeech();
}