java - 如何在树莓派板上使用 java sound api?
问题描述
我在 Raspberry pi board 中使用下面的语音识别器代码。为了传输文件,我将jar
文件从 eclipse 导出到 raspberry pi board。
Jar 文件在 Windows 环境中正常工作,但不适用于 Rasbian OS。windows end rasbian 中的 Java 版本是1.8.0_211。
Rasbian 见 usb 麦克风。(使用 pulseaudio 音量控制)
错误信息:
CLI 中无法使用麦克风”有什么问题?
代码:
/*
* Starting a Thread that checks if the resources needed to the
* SpeechRecognition library are available
*/
public void startResourcesThread() {
//Check lock
if (resourcesThreadRunning)
logger.log(Level.INFO, "Resources Thread already running...\n");
else
//Submit to ExecutorService
eventsExecutorService.submit(() -> {
try {
//Lock
resourcesThreadRunning = true;
// Detect if the microphone is available
while (true) {
//Is the Microphone Available
if (!AudioSystem.isLineSupported(Port.Info.MICROPHONE))
logger.log(Level.INFO, "Microphone is not available.\n");
// Sleep some period
Thread.sleep(350);
}
} catch (InterruptedException ex) {
logger.log(Level.WARNING, null, ex);
resourcesThreadRunning = false;
}
});
}
解决方案
推荐阅读
- python - TypeError:'str'对象不是可调用的带有变量的python
- mariadb - 简化 rundeck 集群
- python - 在scrapy中重定向中间件不起作用
- laravel - Vue / Vuetify / Laravel - 存储多个文件输入
- ios - 导航栏“hidesBarOnSwipe”的动画延迟
- sparql - 使用 SPARQL 查询具有特定主题的属性
- reactjs - 更改 reactbootstrap 导航栏切换图标。(样式化组件)
- webgl - 在 WebGL 中实现阴影的问题
- r - data.table:通过具有多个分组变量的组选择具有最大值的行
- javascript - django链接表行查看