我无法导入google.cloud.speech
from google.cloud import speech
Run Code Online (Sandbox Code Playgroud)
我用它安装了它:
pip install --upgrade google-cloud-speech -t dir-name
Run Code Online (Sandbox Code Playgroud)
从dir-name导入时,它给出了以下错误
ImportError: No module named google.cloud
Run Code Online (Sandbox Code Playgroud)
包含所有子包的google包在那里,但在每个子包中也没有__init__ .py.
如何在不在包文件夹中添加__init__ .py的情况下导入此包?
PS:我也尝试过__future__ import absolute_import,但它无法正常工作.
python-import python-2.7 google-speech-api google-cloud-speech
我想从网络流式传输音频,然后使用python google-cloud-speechAPI 将其转换为文本。我已经将其集成到我的Django频道代码中。
对于前端,我直接复制了此代码,而后端则具有此代码(请参见下文)。现在,问题来了,我没有收到任何异常或错误,但是我没有从Google API得到任何结果...
我试过的
process函数循环中,控件永远不会到达循环内部。我在这里遍历了Java代码,并试图理解它...我已经在本地设置了Java代码并对其进行了调试。我了解的一件事是在Java代码中,该方法onWebSocketBinary正在接收一个整数数组,从前端我们像这样发送
socket.send(Int16Array.from(floatSamples.map(function (n) {return n * MAX_INT;})));
Run Code Online (Sandbox Code Playgroud)在Java中,它们将转换为字节串,然后发送给Google。在django中,我放了调试点,并注意到我正在以二进制字符串形式获取数据...因此,我觉得我不需要执行任何操作...但是,我尝试了几种方法将其转换为整数数组,但是没有用,因为google期望以字节为单位...(您可以在下面看到带注释的代码)
谁能帮我???
Django代码:
import json
from channels.generic.websocket import WebsocketConsumer
# Imports the Google Cloud client library
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
# Instantiates a client
client = speech.SpeechClient()
language_code = "en-US"
streaming_config = None
class SpeechToTextConsumer(WebsocketConsumer):
def connect(self):
self.accept()
def disconnect(self, close_code):
pass …Run Code Online (Sandbox Code Playgroud) django speech-to-text google-speech-api django-channels google-cloud-speech
可以使用Google的语音识别API通过执行请求来获取音频文件(WAV,MP3等)的转录 http://www.google.com/speech-api/v2/recognize?...
示例:我在WAV文件中说过" 一二三五 ".谷歌API给了我这个:
{
u'alternative':
[
{u'transcript': u'12345'},
{u'transcript': u'1 2 3 4 5'},
{u'transcript': u'one two three four five'}
],
u'final': True
}
Run Code Online (Sandbox Code Playgroud)
问题:是否可以获得每个单词的时间(以秒为单位)?
用我的例子:
['one', 0.23, 0.80], ['two', 1.03, 1.45], ['three', 1.79, 2.35], etc.
Run Code Online (Sandbox Code Playgroud)
即,
在时间00:00:00.23和00:00:00.80之间已经说过"一个"字样,在时间00:00:01.03和00:00:01.45(以秒为单位)之间说出了"两个"字样.
PS:寻找支持除英语之外的其他语言的API,尤其是法语.
audio speech-recognition speech speech-to-text google-speech-api
我已按照此链接生成API密钥,但在控制台上找不到Speech API.
我关注的应用示例如下:https://github.com/gillesdemey/google-speech-v2/
我一直在收到错误:
您的客户无权获取URL.
有什么问题?
我正在使用Googles这个api: -
https://www.google.com/speech-api/v2/recognize?output=json&lang="+ language_code +"&key ="我的密钥"
用于语音识别,它的工作非常好.
问题在于数字,即,如果我说one two three four结果将是 1234
,如果我说one thousand two hundred thirty four结果仍然是1234.
另一个问题是使用其他语言,即elf德语中的单词eleven.如果你说elf结果是11,而不是精灵.
我知道我们无法控制api但是有任何参数或黑客可以添加到这个api以强制它只返回单词.
有时候响应的结果是正确的,但并非总是如此.
这些是样本回复
1)当我说"一二三四"时
{"result":[{"alternative":[{"transcript":"1234","confidence":0.47215959},{"transcript":"1 2 3 4","confidence":0.25},{"transcript":"one two three four","confidence":0.25},{"transcript":"1 2 34","confidence":0.33333334},{"transcript":"1 to 34","confidence":1}],"final":true}],"result_index":0}
Run Code Online (Sandbox Code Playgroud)
2)当我说"一千二百三十四"时
{"result":[{"alternative":[{"transcript":"1234","confidence":0.94247383},{"transcript":"1.254","confidence":1},{"transcript":"1284","confidence":1},{"transcript":"1244","confidence":1},{"transcript":"1230 4","confidence":1}],"final":true}],"result_index":0}
Run Code Online (Sandbox Code Playgroud)
我做了什么.
检查结果是否为数字,然后按空格分割每个数字并检查结果数组中是否有相同的序列.在此结果中,结果1234变为1 2 3 4并将搜索结果数组中是否存在类似的序列,然后将其转换为单词.在第二种情况下,没有1 2 3 4,因此将坚持原始结果.
这是代码.
String numberPattern = "[0-9]";
Pattern r1 = Pattern.compile(numberPattern);
Matcher m2 = r1.matcher(output);
if (m2.find()) {
char[] digits2 = output.toCharArray();
String …Run Code Online (Sandbox Code Playgroud) 堆栈溢出可能不是问这个问题的最佳位置,但我需要帮助.我有一个mp3文件,我想使用谷歌的语音识别来获取该文件的文本.任何我可以找到文档或示例的想法将不胜感激.
我已经按照谷歌云语音api快速启动请求api使用
curl -s -H "Content-Type: application/json" \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://speech.googleapis.com/v1/speech:recognize \
-d @sync-request.json
Run Code Online (Sandbox Code Playgroud)
和以下链接,但我有错误
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Run Code Online (Sandbox Code Playgroud)
我现在应该怎么做?
Thanx提前
我正在进行网络语音识别.
我发现Google为开发人员提供了一个名为"Google speech API V2"的API.但我注意到每天都有限制使用它.
之后我发现有一个原生的WEB Speech API也可以实现语音识别.它只是在谷歌Chrome和歌剧:
http://caniuse.com/#feat=speech-recognition
那么1.什么是不同的Google Speech API和Web Speech API?他们有关系吗?
谢谢.
我需要在稍微低带宽的环境中运行google speech api.
基于阅读最佳实践,我最好的选择是使用AMR_WB格式.
但是,以下代码不会产生异常,并且我在onError(t: Throwable)方法中没有得到任何响应,但API 在方法中根本没有返回任何值onNext(value: StreamingRecognizeResponse).
如果我改变格式或.setEncoding()从回到一切工作正常.FLACAMR_WBLINEAR16
AudioEmitter.kt
fun start(
encoding: Int = AudioFormat.ENCODING_PCM_16BIT,
channel: Int = AudioFormat.CHANNEL_IN_MONO,
sampleRate: Int = 16000,
subscriber: (ByteString) -> Unit
)
Run Code Online (Sandbox Code Playgroud)
MainActivity.kt
builder.streamingConfig = StreamingRecognitionConfig.newBuilder()
.setConfig(RecognitionConfig.newBuilder()
.setLanguageCode("en-US")
.setEncoding(RecognitionConfig.AudioEncoding.AMR_WB)
.setSampleRateHertz(16000)
.build())
.setInterimResults(true)
.setSingleUtterance(false)
.build()
Run Code Online (Sandbox Code Playgroud) 在REST API的文档和教程(Google Sppech API for Node:https://cloud.google.com/nodejs/apis )中,我的问题是如何在JavaScript中使用Cloud Speech API.有人在任何页面上使用javascript?
谢谢,
蒂亚戈
javascript speech-recognition google-cloud-platform google-speech-api
android ×2
api ×1
audio ×1
django ×1
google-api ×1
java ×1
javascript ×1
kotlin ×1
oauth ×1
python-2.7 ×1
speech ×1