制作一个将文本转换为音频的网站[Google Cloud Text to Speech API]



我是编码初学者。我想使用Google Cloud Text to Speech API制作一个简单的网站。

  1. 带有文本框的网站
  2. 您在文本框中编写文本,然后单击"转换为音频"按钮
  3. 您可以下载由谷歌云文本到语音API制作的MP3文件

我已经阅读了Google Cloud Text to Speech API的官方网站,但找不到解决方案。

我搜索过"开发一个将文本转换为音频的网站"。 我找到了这个网站。 创建 HTML 应用程序以将文本文件转换为音频文件 但是,它没有满足我的要求。

你能给我任何信息来开发一个将文本转换为音频的网站吗?

提前谢谢你。

真诚的,和

我在Google Colaboratory上做了一个python程序。我想在网站上做同样的事情。

from google.colab import drive
drive.mount('/content/drive')
!cp ./drive/'My Drive'/credential.json ./credential.json
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="credential.json"
f= open("text.ssml","w+")
f.write('<speak><prosody rate="slow">hello world</prosody></speak>')
f.close()
!pip install google-cloud-texttospeech
#!/usr/bin/env python
from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()
with open('text.ssml', 'r') as f:
ssml = f.read()
input_text = texttospeech.types.SynthesisInput(ssml=ssml)
voice = texttospeech.types.VoiceSelectionParams(language_code='en-US', name="en-US-Wavenet-A")
audio_config = texttospeech.types.AudioConfig(audio_encoding=texttospeech.enums.AudioEncoding.MP3)
response = client.synthesize_speech(input_text, voice, audio_config)
with open('output.mp3', 'wb') as out:
out.write(response.audio_content)
print('Audio content written to file "output.mp3"')
from google.colab import files
files.download('output.mp3')

为了实现你想要的,正如你所说,你是编码新手,第一件事就是研究GCP文本到语音API。一个好的第一步是遵循可用的快速入门教程使用客户端库文本到语音转换。

至于您对将文本转换为音频的输入框的要求。您需要遵循在 GCP 上部署应用程序的一般准则。 在应用引擎灵活环境中提供机器学习模型

因此,基本上您的步骤是训练模型并通过应用引擎部署提供服务,或者部署将带有 JSON 有效负载的请求发送到文本到语音转换 API 的应用程序。但是你需要做相当多的阅读。希望这有帮助。

如果你想要处理多个TTS(文本到语音转换(提供程序的灵活性(我们至少有4个(,并增强语音的发现,你可能想看看www.api.audio 下面是一个示例 https://docs.api.audio/recipes/create-engaging-newscast

最新更新