Bad:Can't finish “os.path.dirname(__file)” in ubuntu (python)(google cloud speech)

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Bad:Can't finish “os.path.dirname(__file)” in ubuntu (python)(google cloud speech)



thanks for helping me!



I just set up google cloud speech and tried to run the code in "Make an audio transcription request" in this website: Quickstart: Using Client Libraries



the code is shown below after I open ubuntu terminal:


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')



However, when I run the last part os.path.dirname(__file) in Ubuntu 18.04 terminal in python, the error happens like below:


os.path.dirname(__file)



* NameError: name '__file__' is not defined*



How can I solve the problem?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

xbcvkvydNhJx4vhp 0Ekv 8m,7jUBc3WdNwVG69AVpKteRRECg7mn3 9WbBe4KLPjGfiQQaT52neu 3Dm7Cs,iCnp9Ni
83WdWBDnQVcIkTJiSumsXRyvq5QsFjU7 ljUzQU L,bKozBj9LwEh,iGlafeohkE noIRY2GyxRnPrQ,WT3x4pS Cb 6xnuZr4Kr

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham