简体   繁体   English

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

[英]Make a website converting text to audio [Google Cloud Text to Speech API]

I'm a beginner in coding.我是编码初学者。 I would like to make a simple website using Google Cloud Text to Speech API.我想使用 Google Cloud Text to Speech API 制作一个简单的网站。

  1. a web site with a text box带有文本框的网站
  2. you write a text in the text box and click a button "convert to audio"您在文本框中输入文本,然后单击“转换为音频”按钮
  3. you can download mp3 file which is made by google cloud text to speech api您可以下载由谷歌云文本转语音api制作的mp3文件

I have read Google Cloud Text to Speech API's official site , but couldn't find a solution.我已阅读Google Cloud Text to Speech API 的官方网站,但找不到解决方案。

I have searched like "develop a website converting text to audio".我搜索过“开发一个将文本转换为音频的网站”。 I found this site.我找到了这个网站。 Creating an HTML Application to Convert Text Files to Audio Files However, it didn't meet my request. 创建 HTML 应用程序以将文本文件转换为音频文件但是,它不符合我的要求。

Could you give me any information to develop a website converting text to audio?你能给我任何信息来开发一个将文本转换为音频的网站吗?

Thank you in advance.先感谢您。

Sincerely, Kazu真诚的,和

I have made a python program on Google Colaboratory.我在 Google Colaboratory 上做了一个 python 程序。 I would like to do the same thing on a website.我想在网站上做同样的事情。

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')

In order to achieve what you want, as you say you are new to coding the first thing is to research the GCP text-to-speech API.为了实现您想要的,正如您所说,您是编码新手,第一件事就是研究 GCP 文本转语音 API。 A good first step is to follow the quick start tutorial available Using client libraries text-to-speech .良好的第一步是遵循使用客户端库 text-to-speech提供的快速入门教程。

As for your requirements of an input box to convert the text to audio.至于您对输入框的要求,将文本转换为音频。 You need to follow the general guidelines for deploying an application on GCP.您需要遵循在 GCP 上部署应用程序的一般准则。 Serve Machine Learning Model on App Engine Flexible Environment 在 App Engine 柔性环境中提供机器学习模型

so basically your steps would be to train a model and serve via an App engine deployment, or deploying an application which send requests with a json payload to the text-to-speech API.所以基本上你的步骤是训练模型并通过应用程序引擎部署提供服务,或者部署一个应用程序,该应用程序将带有 json 负载的请求发送到文本转语音 API。 But you need to do quite a bit of reading.但是你需要做相当多的阅读。 Hope this helps.希望这可以帮助。

如果您希望灵活地处理多个 TTS(文本到语音)提供程序(我们至少有 4 个),以及增强的语音发现,您可能需要查看www.api.audio这是一个示例https://docs.api .audio/recipes/create-engaging-newscast

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM