I am trying to use Google Speech API to recognize speech, on windows with colab
here is the error
ImportError: cannot import name 'enums' from 'google.cloud.speech_v1'
Anybody knows how to solve this?
Looks like in the new version they have removed enums. Check this link, If you want enums then you have to switch to an old version.
As mentioned in #addno1's answer, enums and types have been removed in the 2.x versions of the library. It seems that you are using a 2.x version of the library, hence the error.
If your code is using the 1.x version of the library and if you would like to upgrade to the latest version of the library, refer to this migration guide(same mentioned in the other answer). You can refer to this quick start for setup instructions and an updated client library code given below.
# Imports the Google Cloud client library
from google.cloud import speech
# Instantiates a client
client = speech.SpeechClient()
# The name of the audio file to transcribe
gcs_uri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw"
audio = speech.RecognitionAudio(uri=gcs_uri)
config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code="en-US",
)
# Detects speech in the audio file
response = client.recognize(config=config, audio=audio)
for result in response.results:
print("Transcript: {}".format(result.alternatives[0].transcript))
If you want to use the older code, you will have to downgrade the library version to 1.3.2 (last 1.x version) by running the pip command
pip install google-cloud-speech==1.3.2
Related
I need to create a optimization problem with the cplex library and julia. I have to use colab for this, I was able to create a colab on the julia template and download the JuMP library. I have a student license on cplex. But when I try to download cplex it gives the following error:
Error building `CPLEX`:
ERROR: LoadError: Unable to install CPLEX.jl.
The versions of CPLEX supported by CPLEX.jl are:
* 12.10
* 20.1
You must download and install one of these versions separately.
You should set the `CPLEX_STUDIO_BINARIES` environment variable to point to
the install location then try again. For example (updating the path to the
correct location if needed):
# On Windows, this might be
ENV["CPLEX_STUDIO_BINARIES"] = "C:\\Program Files\\CPLEX_Studio1210\\cplex\\bin\\x86-64_win\\"
import Pkg
Pkg.add("CPLEX")
Pkg.build("CPLEX")
i tried the import Pkg; Pkg.add("CPLEX") and upload the I uploaded the cplex files on the computer and showed the path there:
ENV["CPLEX_STUDIO_BINARIES"] = "/content/x64_win64"
import Pkg
Pkg.add("CPLEX")
Pkg.build("CPLEX")
I tried to install EZGmail module for Python. When I check my interpreter settings, it shows it as installed in the PyCharm list. I then use this same interpreter for my project, but I get a module not found error when trying to import EZGmail. What should I check?
Looks like you're trying to import the module in a different casing than it's mentioned on the document.
You're trying to do:
import EZGmail
while the Quickstart document says:
import ezgmail
I'm trying to run a tensorflow code in v2.0 and I'mg getting the following error
AttributeError: module 'tensorflow' has no attribute 'logging'
I don't want to simply remove it from the code.
why this code has been removed?
why should I do instead?
tf.logging was for Logging and Summary Operations and in TF 2.0 it has been removed in favor of the open-source absl-py, and to make the main tf.* namespace has functions that will be used more often.
In TF.2 lesser used functions are gone or moved into sub-packages like tf.math
So instead of tf.logging you could:
tf_upgrade_v2 will upgrade script and changes tf.logging to tf.compat.v1.logging
Python logging module can be used instead
Import absl-py library
If you are using someone else's code it's better to install same Tensorflow version as the author used, or downgrade your Tensorflow version. You may wanna try this:
pip install tensorflow==1.15.0
Or if you have gpu:
pip install tensorflow-gpu==1.15.0
You may still get depricated warnings, however you don't need to modify several files replacing tf with tf.compat.v1
I am current running on Debian 8 Jessie with Python 2.7 and the current google-cloud-speech and storage (pip'd in with upgrade today). When I attempt to config it fails with:
ValueError: Protocol message RecognitionConfig has no "enable_automatic_punctuation" field.
from this call:
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=8000,
language_code='en-US',
# Enable automatic punctuation
enable_automatic_punctuation=True)
The call was directly copy/paste'd from "https://cloud.google.com/speech-to-text/docs/automatic-punctuation#speech-enhanced-model-python".
Huh?
enable_automatic_punctuation is only available if you import speech_v1p1beta1 instead of speech_v1. Compare the documentation for RecognitionConfig for both beta and non beta.
Also, in the very same example that you have linked, if you click on View on Github, you can see the following import:
from google.cloud import speech_v1p1beta1 as speech
Also, related to this topic.
EDIT:
Also, that code is on Python 3, and you are using Python 2.7, be aware of that.
I'm new in ELM, and i want to execute this code :
import Html exposing (..)
main =
text "hola yassine"
using elm platfrom 0.16.
Now, when i call http://localhost:8000/test.elm i have this error :
I cannot find module 'Html'.
Module 'Main' is trying to import it.
Potential problems could be:
* Misspelled the module name
* Need to add a source directory or new dependency to elm-package
and when i execute the elm package install elm-lang/html 1.0.0to import it, i have this problem that depend on path :
error
Someone can help me please ?
thanks a lot.
You say you're using Elm 0.16. elm-lang/html was written from scratch for Elm 0.17, which significantly changed basic language features (abolishing signals most notably). You could try using evancz/elm-html 4.0.2 (the last version to support Elm 0.16) or you could upgrade to Elm 0.18 (as of November 2016, the latest version).