- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个现场录音的网址,我正尝试使用 Google Speech to Text API 转录该录音。我正在使用 Cloud Speech to Text API 中的示例代码。但是,问题是当我传递实时 url 时,我没有收到任何输出。以下是我的代码的相关部分。任何帮助将不胜感激!
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
import io
import os
import time
import requests
import numpy as np
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
from urllib.request import urlopen
from datetime import datetime
from datetime import timedelta
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]= "app_creds.json"
def get_stream():
stream = urlopen('streamurl')
duration = 60
begin = datetime.now()
duration = timedelta(seconds=duration)
while datetime.now() - begin < duration:
data = stream.read(8000)
return data
def transcribe_streaming():
"""Streams transcription of the given audio file."""
client = speech.SpeechClient()
content = get_stream()
# In practice, stream should be a generator yielding chunks of audio data.
stream = [content]
requests = (types.StreamingRecognizeRequest(audio_content=chunk)
for chunk in stream)
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code='en-US')
streaming_config = types.StreamingRecognitionConfig(config=config)
# streaming_recognize returns a generator.
responses = client.streaming_recognize(streaming_config, requests)
for response in responses:
# Once the transcription has settled, the first result will contain the
# is_final result. The other results will be for subsequent portions of
# the audio.
for result in response.results:
print('Finished: {}'.format(result.is_final))
print('Stability: {}'.format(result.stability))
alternatives = result.alternatives
# The alternatives are ordered from most likely to least.
for alternative in alternatives:
print('Confidence: {}'.format(alternative.confidence))
print(u'Transcript: {}'.format(alternative.transcript))
最佳答案
向 Google 语音服务发送音频时,请确保服务对象设置与音频编码匹配。在您的特定情况下
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code='en-US')
对应单声道,16KHz,线性16位PCM编码。查看list of other supported encodings如果您需要转录不同格式的音频。
关于python - 如何将实时音频 url 传递给 Google Speech to Text API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57426836/
我只是尝试使用 Microsoft.Speech.dll; 为文本转语音运行简单的 Microsoft 示例 using System; using Microsoft.Speech.Synthesi
微软似乎提供了不少语音识别产品,我想知道它们之间的区别。 有Microsoft Speech API ,或 SAPI。但不知何故Microsoft Cognitive Service Speech A
我希望编写一个应用程序,将语音到文本转换为仓库应用程序,反之亦然。主要用例是运算符(operator)将在仓库中佩戴耳机并将指令发送回服务器并从仓库软件接收指令以拣选和打包订单。我们将使用由 Wind
我正在探索 python 中的谷歌云语音 api。我正在关注这个 link .我也提到了这个 stackoverflow link .但是我对设置环境变量感到震惊。 我做过的事情: 1.安装gclou
在尝试让 Speech to Text(IBM 语音网关 IVR 应用程序)识别字母数字字符串时,我想知道我是否可以创建一个自定义语法或实体来限制 STT 仅识别单个字母和数字,不包括完全的话。例如,
是否可以将来自Web Speech API的合成语音用作Web Audio API音频上下文中的SourceNode? 最佳答案 实际上,我问过要在Web Speech邮件列表中添加此内容,并且基本上
使用 Microsoft Speech API 转录中/大型音频文件(每个文件约 6-10 分钟)的最佳方法是什么?像批处理音频文件转录这样的东西? 我使用了 https://docs.microso
我的 .wav 文件长度只有 4 秒。即使在多次重试并在云端运行后,我仍然不断收到以下错误 * upload completely sent off: 12 out of 12 bytes
我找到了一些描述如何使用 Google 语音 API 的文章 ( http://mikepultz.com/2011/03/accessing-google-speech-api-chrome-11/
我使用 google 语音转文本 API 从音频中获取字幕,但是当音频太长时,通常超过 60 分钟,重试次数过多会失败。它说:google.api_core.exceptions.GoogleAPIC
我有一些来自 System.Speech.Recognition 的简单代码可以正常工作: using (var recognizer = new SpeechRecognitionEngine(ne
Windows 10。我在“设置”中安装了日语 TTS 语音。现在,当我在 Speech API 5.4 OneCore 中使用语音枚举时(虽然不是在 5.4 中),我得到 6 个语音: 大卫 齐拉
当我提交对太长文本的综合请求时,我收到以下错误: google.api_core.exceptions.ResourceExhausted: 429 Received message larger t
我是 C# 的新手,也是 Speech.Recognition 的新手。我搜索了很长时间的教程,但没有找到那么多,我什至不确定我是否正确包含了所有内容。 我下载了: SDK Runtime Langu
我有一个奇怪的要求,即在我现有的应用程序中我有 Text2Speech 并且为此,我使用了 AVSpeechSynthesizer 来语音文本,但现在要求改变了,现在我需要将 HTML 文件数据转换为
我使用 Google Speech API 通过 Python 识别 .OGG 文件音频中的越南语语音。但它不会返回任何结果。 最佳答案 至少在英文版的Google Speech API中,需要使用F
我想从手机录制音频,然后将其发送到谷歌语音非流媒体 API。我可以使用 Capture.captureAudio() 进行录音,但是我不知道音频编码和采样率是什么,因为它们是必需的 for the a
我使用谷歌云语音到文本 API 将音频转换为文本。 对于 .raw文件它工作正常 但是对于 .wav文件它给了我类似的错误: Google::Gax::RetryError Exception: Ga
.NET 中有两个类似的用于语音识别的命名空间和程序集。我试图了解其中的差异以及何时适合使用其中之一。 程序集 System.Speech(在 System.Speech.dll 中)有 System
通过流式 API (Performing Streaming Speech Recognition on an Audio Stream) 使用 Google Cloud Speech API, 我们
我是一名优秀的程序员,十分优秀!