Question

[Solved] ModuleNotFoundError: No module named ‘google.cloud’

I’m looking to use the Google “cloud text to speech” api, and I’m having the common problem of the module not being found. I’ve tried the solutions that most people have, only problem being that I use windows and most of the solutions are for mac or Linux (although this shouldn’t be that big of an issue).

I ran the ‘pip list’ on the command line and here’s what it returned:

google                    2.0.1
google-api-core           1.7.0
google-auth               1.6.3
google-cloud              0.34.0
google-cloud-texttospeech 0.4.0
googleapis-common-protos  1.5.8

And if this helps, this is what I have been running on the import statement (this is also taken from google’s tutorial)

>> from google.cloud import texttospeech

from google.cloud import texttospeech
ModuleNotFoundError: No module named 'google.cloud'

Any solutions?

Enquirer: Landon G

||

Solution #1:

ModuleNotFoundError: No module named ‘google.cloud’

To solve this problem:

  1. Remove google-cloud: pip uninstall google-cloud
  2. Reinstall with update google-cloud-texttospeech: pip install --upgrade google-cloud-texttospeech

The library google-cloud is deprecated. Do not install this library or use it.

Example code to get you started with Text to Speech:

from google.cloud import texttospeech

# Instantiates a client
client = texttospeech.TextToSpeechClient()

# Set the text input to be synthesized
synthesis_input = texttospeech.types.SynthesisInput(text="Hello, World!")

# Build the voice request, select the language code ("en-US") and the ssml
# voice gender ("neutral")
voice = texttospeech.types.VoiceSelectionParams(
    language_code='en-US',
    ssml_gender=texttospeech.enums.SsmlVoiceGender.NEUTRAL)

# Select the type of audio file you want returned
audio_config = texttospeech.types.AudioConfig(
    audio_encoding=texttospeech.enums.AudioEncoding.MP3)

# Perform the text-to-speech request on the text input with the selected
# voice parameters and audio file type
response = client.synthesize_speech(synthesis_input, voice, audio_config)

# The response's audio_content is binary.
with open('output.mp3', 'wb') as out:
    # Write the response to the output file.
    out.write(response.audio_content)
    print('Audio content written to file "output.mp3"')
Respondent: John Hanley

Solution #2:

pip3 install google-cloud-bigquery

this worked for me

Respondent: Brandon Stewart

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy