如果由于用户不说话而在RecognizerIntent完成的情况下如何处理图像(ImageView)的可见性
if (RecognizerIntent.EXTRA_RESULTS == null){
image1.setVisibility(View.VISIBLE);///microphone icon
}
Run Code Online (Sandbox Code Playgroud)
要么
if (RecognizerIntent.ACTION_RECOGNIZE_SPEECH == null){
image1.setVisibility(View.INVISIBLE);///microphone
}
Run Code Online (Sandbox Code Playgroud)
日Thnx
我有一个输入类型的文本字段,其属性为x-webkit-speech.
<input type="text" placeholder="name" x-webkit-speech>
Run Code Online (Sandbox Code Playgroud)
它适用于chrome,但不适用于Firefox.任何人都知道在Firefox中是否支持它?
编辑:有没有可用的js/bootstrap插件?
我正在开发一个语音识别系统,我用英语制作了一个,它运作得很好.
但我遇到的问题是我需要开发应用程序以识别阿拉伯语.
这是我的代码:
private static final int RESULT_SPEECH = 1;
Button b1 ;
ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv = (ListView) findViewById(R.id.listView1);
b1 = (Button) findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent voicerecogize = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
voicerecogize.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "ar-eg");
startActivityForResult(voicerecogize, RESULT_SPEECH);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == RESULT_SPEECH && requestCode == RESULT_OK);
{
ArrayList<String > results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , results));
} …
Run Code Online (Sandbox Code Playgroud) 如何绘制来自麦克风的 matplotlib 输入信号?我尝试用 plt.plot(frames) 进行绘图,但由于某种原因,frames 是一个字符串?
a) 为什么frames变量是一个字符串列表?
b) 为什么数据变量是字符串列表?
c) 它们应该代表单个样本的能量/幅度并且是整数吗?
d) 当我指定块大小为 1024 时,为什么数据长度为 2048?
(我猜是因为我使用 paInt16,但仍然看不出为什么它不能是 1024)
我有以下用于麦克风输入的代码:
import pyaudio
import audioop
import matplotlib.pyplot as plt
import numpy as np
from itertools import izip
import wave
FORMAT = pyaudio.paInt16 # We use 16bit format per sample
CHANNELS = 1
RATE = 44100
CHUNK = 1024 # 1024bytes of data red from a buffer
RECORD_SECONDS = 3
WAVE_OUTPUT_FILENAME = "file.wav"
audio = pyaudio.PyAudio()
# start Recording
stream = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Pocketsphinx 提取每个段的开始和结束时间戳。下面的代码用于提取单词标记。如何访问时间戳?
我试过在这里查看文档http://cmusphinx.sourceforge.net/doc/pocketsphinx/index.html但找不到方法
#!/usr/bin/env python
import os
import sphinxbase as sb
import pocketsphinx as ps
MODELDIR = 'deps/pocketsphinx/model'
DATADIR = 'deps/pocketsphinx/test/data'
# Create a decoder with certain model
config = ps.Decoder.default_config()
config.set_string('-hmm', os.path.join(MODELDIR, 'en-us/en-us'))
config.set_string('-lm', os.path.join(MODELDIR, 'en-us/en-us.lm.bin'))
config.set_string('-dict', os.path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
decoder = ps.Decoder(config)
# Decode streaming data.
decoder.start_utt()
stream = open(os.path.join(DATADIR, 'goforward.raw'), 'rb')
while True:
buf = stream.read(1024)
if buf:
decoder.process_raw(buf, False, False)
else:
break
decoder.end_utt()
stream.close()
print('Best hypothesis segments:', [seg.word for seg in decoder.seg()])
Run Code Online (Sandbox Code Playgroud) 我已经在 python 中安装并设置了 pocketsphinx 和 sphinxbase 包。我还为 github 获取了语音识别代码,并根据要求更改了数据和模式目录,但是当我尝试通过“python test.py”运行它时仍然无法通过语音进行流式传输这里是代码:
#!/usr/bin/env python
import os
import sphinxbase as sb
import pocketsphinx as ps
MODELDIR = '/usr/lib/python2.7/site-packages/speech_recognition/pocketsphinx-data'
DATADIR='/usr/lib/python2.7/site-packages/speech_recognition/pocketsphinx-data'
# Create a decoder with certain model
config = ps.Decoder.default_config()
config.set_string('-hmm', "/usr/lib/python2.7/site-packages/speech_recognition/pocketsphinx-data/en-US/acoustic-model")
config.set_string('-lm', os.path.join(MODELDIR, 'en-US/language-model.lm.bin'))
config.set_string('-dict', os.path.join(MODELDIR, 'en-US/pronounciation-dictionary.dict'))
decoder = ps.Decoder(config)
# Decode streaming data.
decoder.start_utt()
stream = open(os.path.join(DATADIR, 'en-US/goforward.raw'), 'rb')
while True:
buf = stream.read(1024)
if buf:
decoder.process_raw(buf, False, False)
else:
break
decoder.end_utt()
stream.close()
print('Best hypothesis segments:', [seg.word for seg in decoder.seg()])
Run Code Online (Sandbox Code Playgroud)
请告诉我如何执行它。
我正在开发 Bot 应用程序,这里有 2 个功能
两者都按预期工作,但我想检测到当用户当时停止说话时,我想停止检测并将该数据发送到服务器。
有没有办法让那个用户不说话?
我正在使用以下代码进行语音检测:
// Starts an AVAudio Session
NSError *error;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
[audioSession setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&error];
// Starts a recognition process, in the block it logs the input or stops the audio
// process if there's an error.
recognitionRequest = [[SFSpeechAudioBufferRecognitionRequest alloc] init];
AVAudioInputNode *inputNode = audioEngine.inputNode;
recognitionRequest.shouldReportPartialResults = YES;
recognitionTask = [speechRecognizer recognitionTaskWithRequest:recognitionRequest resultHandler:^(SFSpeechRecognitionResult * _Nullable result, NSError * _Nullable error) {
BOOL isFinal = NO; …
Run Code Online (Sandbox Code Playgroud) 我想使用 Python 的 SpeechRecognition 库,但是当我尝试运行一个使用麦克风的程序时,我打算这样做,我收到错误
“需要 PyAudio 0.2.11 或更高版本(找到版本 0.2.9)”
所以我做了一些挖掘并找到了如何使用 apt-get 安装它。不幸的是,我运行 Fedora 26,所以我必须使用 yum 来安装我的软件包,当我寻找使用它安装 PyAudio 的方法时,我只能找到 0.2.9 版。
每当我尝试做
pip 安装 pyaudio
我收到以下错误:
pyaudio 的构建轮失败运行 setup.py clean for pyaudio 无法构建 pyaudio 安装收集的包:pyaudio 运行 setup.py install for pyaudio ...错误命令 /usr/bin/python2 -u -c "import setuptools,标记化;文件='/tmp/pip-build-ZiuxD3/pyaudio/setup.py';f=getattr(tokenize, 'open', open)( file );code=f.read().replace('\r \n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-a2Iwxv-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py 创建构建创建构建/lib .linux-x86_64-2.7 复制 src/pyaudio.py -> build/lib.linux-x86_64-2.7 运行 build_ext 构建 '_portaudio' 扩展创建 build/temp.linux-x86_64-2.7 …
我正在尝试创建一个应用程序,当用户不知道时,它会显示一个会更改每个级别的文本。目标是说出一个显示的句子(是的,它是为孩子们设计的):
\n\n@IBAction func dontknow(_ sender: Any) {\n let utterance = AVSpeechUtterance(string: textLabel.text)\n utterance.voice = AVSpeechSynthesisVoice(language: "fr-FR")\n utterance.rate = 0.4\n\n let synthesizer = AVSpeechSynthesizer()\n synthesizer.speak(utterance)\n\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n该应用程序的构造如下:\n如果用户不知道 -> 他可以单击按钮说出文本\n如果他是对的 -> 他进入下一个级别。
\n\n当他第一次输入要说的按钮时,应用程序会说一些话,但是当用户尝试说出文本并且在下一个级别时,他单击要说的按钮,则什么也没有发生。它只是抛出这个错误:Failure starting audio queue \xe2\x89\xa5\xcb\x9a\xcb\x9b\xcb\x87
完整代码:
\n\nimport UIKit\nimport AVFoundation\nimport Speech\n\nclass ReadViewController: UIViewController, SFSpeechRecognizerDelegate {\n var texts = ["Je mange des p\xc3\xa2tes", "Bonjour Jean comment vas-tu", "Qui est-ce", "J\'en ai marre", "Je ne te trouve pas gentil", "Pourquoi tu ne veux pas","Tu es si gentil", "Tu …
Run Code Online (Sandbox Code Playgroud) speech-recognition avfoundation ios swift sfspeechrecognizer
我正在使用谷歌语音库,如下所示:
from google_speech import Speech
# say "Hello World"
text = "Hello World"
lang = "en"
speech = Speech(text, lang)
speech.play()
Run Code Online (Sandbox Code Playgroud)
收到此错误:
RuntimeError
Traceback (most recent call last)
<ipython-input-2-4daa3294f636> in <module>()
----> 1 from google_speech import Speech
2
3 # say "Hello World"
4 text = "Hello World"
5 lang = "en"
D:\soft\Ins\anac\lib\site-packages\google_speech\__init__.py in <module>()
321
322 # check deps
--> 323 bin_dep.check_bin_dependency(("sox",))
324
325
D:\soft\Ins\anac\lib\site-packages\google_speech\bin_dep.py in check_bin_dependency(bins)
5 for bin in bins:
6 if shutil.which(bin) is None:
----> 7 …
Run Code Online (Sandbox Code Playgroud) python ×3
android ×2
ios ×2
avfoundation ×1
cmusphinx ×1
fedora ×1
html5 ×1
input ×1
java ×1
matplotlib ×1
objective-c ×1
pyaudio ×1
python-2.7 ×1
redhat ×1
sox ×1
swift ×1
windows ×1