本文代码演示如何将音频文件转录为文本格式。使用IBM Speech to Text API,文档地址https://speech-to-text-demo.ng.bluemix.net/。
apikey = 'Your API key'
url = 'Your url'
import json
import os
from ibm_watson import SpeechToTextV1
from ibm_watson.websocket import RecognizeCallback, AudioSource
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
# 首先进行身份认证
authenticator = IAMAuthenticator(apikey)
speech_to_text = SpeechToTextV1(
authenticator=authenticator
)
speech_to_text