簡體   English   中英

錯誤:FileNotFoundError:[Errno 2] 沒有這樣的文件或目錄

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM