1

我一直在尝试开发一个 python 脚本来从嘈杂的音频文件中转录音频。我的具体用例是正确转录嘈杂的音频部分。当我将文件发送到 SpeechML API 进行处理时,对于嘈杂的音频,响应要么省略要么不正确。有没有办法解决这个问题?我已经尝试过一些工具,比如 sox、语音识别包装器,但它们没有帮助下面是我正在使用的代码

def transcribe_gcs(gcs_uri):
"""Asynchronously transcribes the audio file specified by the gcs_uri."""
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types

client = speech.SpeechClient()
audio = types.RecognitionAudio(uri=gcs_uri)
config = types.RecognitionConfig(
         encoding=enums.RecognitionConfig.AudioEncoding.FLAC,
         sample_rate_hertz=48000,
         language_code='en-US')

operation = client.long_running_recognize(config, audio)
print('Waiting for operation to complete...')
response = operation.result(timeout=600)
# Each result is for a consecutive portion of the audio. Iterate through
# them to get the transcripts for the entire audio file.
for result in response.results:
# The first alternative is the most likely one for this portion.
    print('Transcript: {}'.format(result.alternatives[0].transcript))
    print('Confidence: {}'.format(result.alternatives[0].confidence))
# [END def_transcribe_gcs]

如果名称== '主要':

gcs_uri="gs://speechmldemo/outputclear.flac"   
transcribe_gcs(gcs_uri)
4

1 回答 1

2

到目前为止,我知道语音 API 结果的质量将始终在很大程度上取决于外部噪音和录音的整体质量。我能想到的能显着改善你的结果的唯一方法是:

  1. 尽可能降低源头的噪音水平(在录音时)
  2. 在处理之前以数字方式滤除噪声,去除人类语音未使用的频带。(向上 4 KHz 是电话的标准)
  3. 最好使用未压缩的音频文件(即 wav),以避免压缩质量损失(就像 mp3 一样。)

您可能会在官方文档中找到改进处理的其他提示

于 2018-02-01T10:38:28.733 回答