本文介绍了错误:FileNotFoundError:[Errno 2]没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用ubuntu和python运行Google云语音.首先,我将所有代码放在一个名为lu.py
的文件中:
I use ubuntu and python to run google cloud speech. First I put all the code in a file called 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
时,它说
When I ran python lu.py
in terminal, it said
FileNotFoundError: [Errno 2] No such file or directory: 'resources/audio.raw'
我对路径问题不熟悉,所以我不知道哪里出了问题.
I'm not familiar with the path problem, so I don't know where is wrong.
推荐答案
意味着在路径resources/[filename]
means file that contains the name audio.raw was not found in the path resources/[filename]
您可以在此注释下方的块中设置路径名称:
You can set the path name in the block below this comment:
# The name of the audio file to transcribe
这篇关于错误:FileNotFoundError:[Errno 2]没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!