java text to speech_Java TextToSpeech.speak方法代码示例
import android.speech.tts.TextToSpeech; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
handler = new Handler();
// Set the resources locale
String languageExtra = getIntent().getStringExtra(SupportedLanguage.class.getSimpleName());
final SupportedLanguage language = languageExtra == null ? SupportedLanguage.ENGLISH : SupportedLanguage.valueOf(languageExtra);
LocaleUtils.setResourcesLocale(language.getLocale(), this);
// Load configuration
InputStream inputStream = null;
try {
inputStream = getBaseContext().getAssets().open("application.properties");
applicationProperties.load(inputStream);
} catch (IOException e) {
Log.e(TAG, "Unable to load application.properties", e);
} finally {
IOUtils.closeQuietly(inputStream);
}
// Get the cloudSightService
String cloudSightApiKey = applicationProperties.getProperty("cloudSight.apiKey");
cloudSightService = new CloudSightServiceImpl(cloudSightApiKey);
// Initialize the activity content
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photo_analysis);
// Display the photo
final byte[] photo = getIntent().getByteArrayExtra(INTENT_PHOTO_EXTRA);
ImageView photoImageView = (ImageView) findViewById(R.id.photoImageView);
photoImageView.setImageBitmap(BitmapFactory.decodeByteArray(photo, 0, photo.length));
// Load the TTS engine
textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.ERROR) {
Toast.makeText(PhotoAnalysisActivity.this, R.string.error_tts_engine, Toast.LENGTH_SHORT).show();
} else {
textToSpeech.setLanguage(language.getLocale());
// Send the photo to Cloud Sight API to analyze the photo
Toast.makeText(PhotoAnalysisActivity.this, R.string.analyze_photo, Toast.LENGTH_SHORT).show();
textToSpeech.speak(getResources().getString(R.string.analyze_photo), TextToSpeech.QUEUE_ADD, null);
new AnalyzePhotoTask(photo, language).execute();
}
}
});
}
java text to speech_Java TextToSpeech.speak方法代码示例相关推荐
- java text to speech_Java TextToSpeech.speak方法代碼示例
import android.speech.tts.TextToSpeech; //導入方法依賴的package包/類 @Override protected void onCreate(Bundle ...
- java secretkey用法_Java SecretKeyFactory.generateSecret方法代码示例
本文整理汇总了Java中javax.crypto.SecretKeyFactory.generateSecret方法的典型用法代码示例.如果您正苦于以下问题:Java SecretKeyFactory ...
- java gc 例子_Java GC.drawImage方法代码示例
import org.eclipse.swt.graphics.GC; //导入方法依赖的package包/类 void paintElement(PaintEvent e) { GC g = e.g ...
- java polygon 用法_Java Polygon.getBounds方法代码示例
import java.awt.Polygon; //导入方法依赖的package包/类 private SelectionShape translatePointsToRealSize(Select ...
- java jframe案例_Java JFrame.setMinimumSize方法代码示例
import javax.swing.JFrame; //导入方法依赖的package包/类 public static void main(String... args) throws Throwa ...
- java settext用法_Java JFormattedTextField.setText方法代码示例
import javax.swing.JFormattedTextField; //导入方法依赖的package包/类 /** * Creates a {@link JFormattedTextFie ...
- java makedir用法_Java Files.makeDir方法代码示例
import org.nutz.lang.Files; //导入方法依赖的package包/类 protected void download(String openid, String media_ ...
- java args包_Java Args.positive方法代码示例
import org.apache.http.util.Args; //导入方法依赖的package包/类 /** * Creates new instance of BHttpConnectionB ...
- java shape用法_Java PShape.scale方法代码示例
import processing.core.PShape; //导入方法依赖的package包/类 public void updateAnim(){ if(pg_src_small == null ...
- java round指令_Java PApplet.round方法代码示例
import processing.core.PApplet; //导入方法依赖的package包/类 public static final void updatePos() { if(follow ...
最新文章
- 技术是最求 买卖是境界
- C/Cpp / #include
- 使用Chrome快速实现数据的抓取(四)——优点
- [转]C# 将类的内容写成JSON格式的字符串
- 面对面交流的好处_我们的交流方式是如何被网络社交媒体一步步改变的
- Hiv:SQuirrel连接hive配置
- vs2010中MEX文件建立与调试
- 查看Oracle当前用户下的信息
- 计算机二级2018VB题库百度云,2018年春江苏省计算机二级VB考试真题第1套
- charles安卓抓包步骤详解
- unity 屏幕虚拟键盘
- 4千多个表情斗图图片大全ACCESS\EXCEL
- 【C++】算法STL库
- Android 7.0 插卡后APN信息的加载流程、UI界面编辑APN的流程及Android中APN配置相关的漏洞
- nn.Bilinear讲解
- 几次安全实习面试简单记录
- Android 开发 设置banner圆角,滑动时,图片圆角失效
- 再见 Docker,是时候拥抱下一代容器工具 Containerd 了!
- 前端构建工具-gulp !(解决浏览器缓存问题)
- ls 如何给文件名中数字排序