[英]Bad: FileNotFoundError: [Errno 2] No such file or directory
我使用 ubuntu 和 python 来运行谷歌云语音。 首先,我将所有代码放在一个名为lu.py
的文件中:
import io
import os
from google.cloud import speech
...
# The name of the audio file to transcribe
file_name = os.path.join(
os.path.dirname(__file__),
'resources',
'audio.raw')
# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file:
content = audio_file.read()
audio = types.RecognitionAudio(content=content)
...
当我在终端中运行python lu.py
时,它说
FileNotFoundError: [Errno 2] No such file or directory: 'resources/audio.raw'
路径问题我不熟悉,所以不知道哪里错了。
表示在路径 resources/[filename] 中找不到包含名称 audio.raw 的文件
您可以在此注释下方的块中设置路径名:
# The name of the audio file to transcribe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.