在我在 GitHub 上找到的示例的帮助下,我的代码目前能够读取音频文件并使用 Azure Speech to Text 进行转录。但是,我需要在转录中包含所有单词的时间戳。根据文档,此功能是在 1.5.0 版中添加的,可通过方法 request_word_level_timestamps() 访问。但即使我打电话给它,我也得到和以前一样的回应。我无法从文档中弄清楚如何使用它。有谁知道它是如何工作的?
我使用的是 Python SDK 1.5.1 版。
import azure.cognitiveservices.speech as speechsdk
import time
from allennlp.predictors.predictor import Predictor
import json
inputPath = "(inputlocation)"
outputPath = "(outputlocation)"
# Creates an instance of a speech config with specified subscription key and service region.
# Replace with your own subscription key and service region (e.g., "westus").
speech_key, service_region = "apikey", "region"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
speech_config.request_word_level_timestamps()
speech_config.output_format=speechsdk.OutputFormat.Detailed
#print("VALUE: " + speech_config.get_property(property_id=speechsdk.PropertyId.SpeechServic eResponse_RequestWordLevelTimestamps))
filename = …Run Code Online (Sandbox Code Playgroud)