我是Python的新手,希望实现Google API提供的用于语音到文本的代码。添加存储桶名称后,我收到以下错误:
TypeError: startswith() takes at least 1 argument (0 given)
我尝试将path函数转换为字符串,但仍然收到错误。我遗漏了什么?请看我下面的代码。
parser = argparse.ArgumentParser(
description='Speech to text from video file', formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument('--path', help="File or GCS path for audio file to be recognized")
parser.add_argument(
"--model",
help="The speech recognition model to use",
choices=["command_and_search", "phone_call", "video", "default"],
default="default",
)
args = parser.parse_args()
print(args)
path=("gs://parabilis-june-webinar")
path.startswith().toString().startsWith("gs://example-june-webinar")
if args.path.startswith("gs://example-webinar"):
transcribe_model_selection_gcs(args.path, args.model)
else:
transcribe_model_selection(args.path, args.model)```
[1]: https://github.com/googleapis/python-speech/blob/HEAD/samples/snippets/transcribe_model_selection.py发布于 2021-07-06 10:46:34
我认为你需要这样的东西:
path.startsWith("gs://example-june-webinar")这将在您的用例中返回True,您可以在您的用例中使用它。
https://stackoverflow.com/questions/68263389
复制相似问题