Error script Ironpython

-- coding: utf-8 --

import sys
sys.path.append(r"C:\Users\alex6\Desktop\OB\Lib\site-packages")
import os
from google.cloud import speech

client = speech.SpeechClient()
gcs_uri = “C:\Users\alex6\Desktop\OB\sound.wav”
audio = speech.RecognitionAudio(uri=gcs_uri)
config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
language_code=“fr-FR”,
)
response = client.recognize(config=config, audio=audio)
print(response)

It result with an error : SyntaxerrorException Unexpected token ‘:’

could you help me please

You know you have to close out each command with a ; right?

Also it should give you a line and column number to tell you where the error was

mmhh i m very beginner i learn python for 2day lol

-- coding: utf-8 --

import sys
sys.path.append(r"C:\Users\alex6\Desktop\OB\Lib\site-packages")
import os
from google.cloud import speech

client = speech.SpeechClient();
gcs_uri = “C:\Users\alex6\Desktop\OB\sound.wav”;
audio = speech.RecognitionAudio(uri=gcs_uri);
config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
language_code=“fr-FR”,
);
response = client.recognize(config=config, audio=audio);
print(response);

i do that is it correct ? but it don’t give me a line

They also belong on the imports and sys.path line

Canyou take a screenshot of the error

Capture d’écran 2021-10-06 001919

Try adding print debug lines to figure out exactly where it is failing

nvm that wont work, its failing to compile

Also with python, formating is very important. Things that need indents all need to use the same indents (4 spaces or 1 tab), mixing them will cause an error

import sys;
sys.path.append(r"C:\Users\alex6\Desktop\OB\Lib\site-packages");
import os;
from google.cloud import speech;

client = speech.SpeechClient();
gcs_uri = “C:\Users\alex6\Desktop\OB\sound.wav”;
audio = speech.RecognitionAudio(uri=gcs_uri);
config = speech.RecognitionConfig(
    encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
    language_code=“fr-FR” );
response = client.recognize(config=config, audio=audio);
print(response);

I’m pretty sure python doesn’t need the semicolon at the end btw ^^

I dont think it mattered in 2.7 but either 3 or 3.5 or 3.7 it was always bugging me to include them however I might be mixing it up with C# (which always needed them)

import sys,os

sys.path.append('C:/Users/alex6/Desktop/OB/Lib/site-packages')

from google.cloud import speech

client = speech.SpeechClient()

gcs_uri = "C:/Users/alex6/Desktop/OB/sound.wav"

audio = speech.RecognitionAudio(uri=gcs_uri)

config = speech.RecognitionConfig(encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,language_code="fr-FR")

response = client.recognize(config=config,audio=audio)

print(response)

If this has the same error with : then the package isn’t compatible with iron py.

edit: 99% sure that error about : was caused because you improperly typed the paths. The line break \ separates the : from the rest of the string. A random : in the middle of the string will error.