坏:Can';“t完成”;os.path.dirname(_文件)";在ubuntu(python)(谷歌云演讲)
谢谢你帮助我 我刚刚设置了google cloud speech,并尝试运行该网站“发出音频转录请求”中的代码: 打开ubuntu终端后,代码如下所示:坏:Can';“t完成”;os.path.dirname(_文件)";在ubuntu(python)(谷歌云演讲),python,ubuntu,google-cloud-speech,Python,Ubuntu,Google Cloud Speech,谢谢你帮助我 我刚刚设置了google cloud speech,并尝试运行该网站“发出音频转录请求”中的代码: 打开ubuntu终端后,代码如下所示: export GOOGLE_APPLICATION_CREDENTIALS="/home/luffy/Lumariatuan-xxxxxxxxxxxx.json" python import io import os from google.cloud import speech from google.cloud.speech im
export GOOGLE_APPLICATION_CREDENTIALS="/home/luffy/Lumariatuan-xxxxxxxxxxxx.json"
python
import io
import os
from google.cloud import speech
from google.cloud.speech import enums
from google.cloud.speech import types
client = speech.SpeechClient()
# The name of the audio file to transcribe
file_name = os.path.join(
os.path.dirname(__file__),
'resources',
'audio.raw')
但是,当我在python的Ubuntu 18.04终端中运行最后一部分os.path.dirname(_文件)
时,出现如下错误:
*名称错误:未定义名称“\uuuu文件”*
如何解决此问题?file变量包含Python当前导入的文件的路径。您可以在模块内使用此变量来查找模块的路径。它不适用于交互式python终端。您可以看看是否<代码>\uuuuu文件\uuuuuu需要在一个文件中您不能在终端中执行此操作,请尝试在.py文件中使用它谢谢@madham和@dilkash!我把所有的代码放在一个.py文件中,我解决了这个问题!但是,当我继续运行代码时,会出现另一个问题。你能让我停下来看看吗?谢谢在这里:@madham或@dilkash你能不能把你的评论作为一个答案发布出来,这样就能被鲁黄接受?