我希望使用Google的“云文本语音转换” API,但遇到的常见问题是找不到该模块。我已经尝试了大多数人拥有的解决方案,唯一的问题是我使用Windows,并且大多数解决方案都适用于Mac或Linux(尽管这不应该是一个大问题)。
我在命令行上运行了“点列表”,这是它返回的内容:
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
如果有帮助,这就是我在import语句上运行的内容(这也取自Google的教程)
>> from google.cloud import texttospeech
from google.cloud import texttospeech
ModuleNotFoundError: No module named 'google.cloud'
有解决方案吗?
答案 0 :(得分:1)
ModuleNotFoundError:没有名为“ google.cloud”的模块
要解决此问题:
pip uninstall google-cloud
pip install --upgrade google-cloud-textdtospeech
已弃用Google-cloud库。不要安装或使用此库。
示例代码可帮助您开始使用文本到语音:
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"')
答案 1 :(得分:0)
pip3 安装 google-cloud-bigquery
这对我有用