ModuleNotFoundError: No module named 'google.cloud'
ModuleNotFoundError: No module named 'google.cloud'
我想使用 Google "cloud text to speech" api,但我遇到了找不到模块的常见问题。我已经尝试了大多数人的解决方案,唯一的问题是我使用 windows 并且大多数解决方案都是针对 mac 或 Linux (尽管这不应该那么大一个问题)。
我在命令行上 运行 'pip list' 返回的是:
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
如果这有帮助,这就是我在导入语句中 运行 所做的(这也摘自 google 的教程)
>> from google.cloud import texttospeech
from google.cloud import texttospeech
ModuleNotFoundError: No module named 'google.cloud'
有什么解决办法吗?
ModuleNotFoundError: No module named 'google.cloud'
解决这个问题:
- 删除google-云:
pip uninstall google-cloud
- 使用更新重新安装 google-cloud-texttospeech:
pip install --upgrade google-cloud-texttospeech
库 google-cloud
已弃用。不要安装或使用此库。
让您开始使用 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"')
pip3 安装 google-cloud-bigquery
这对我有用
我想使用 Google "cloud text to speech" api,但我遇到了找不到模块的常见问题。我已经尝试了大多数人的解决方案,唯一的问题是我使用 windows 并且大多数解决方案都是针对 mac 或 Linux (尽管这不应该那么大一个问题)。
我在命令行上 运行 'pip list' 返回的是:
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
如果这有帮助,这就是我在导入语句中 运行 所做的(这也摘自 google 的教程)
>> from google.cloud import texttospeech
from google.cloud import texttospeech
ModuleNotFoundError: No module named 'google.cloud'
有什么解决办法吗?
ModuleNotFoundError: No module named 'google.cloud'
解决这个问题:
- 删除google-云:
pip uninstall google-cloud
- 使用更新重新安装 google-cloud-texttospeech:
pip install --upgrade google-cloud-texttospeech
库 google-cloud
已弃用。不要安装或使用此库。
让您开始使用 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"')
pip3 安装 google-cloud-bigquery
这对我有用