刚刚逆向出来的谷歌文字转语音(TTS),可直接调用

我什么都没加,就是原样复制你们的代码,粘贴的时候最下面会多出翻译两个汉字,部署一直报错,才发现的,我也不知道什么原因

额,我试了下,我以为是chat-TTS,那个语音,原来是微软语音啊。微软语音不用这么复杂吧,这类软件挺多的

上面老哥逆向的谷歌tts呀

我以为是之前出的那个chatTTS,这个的话语音能力和浏览器语音没多大区别

Mark

大哥逆一下简映啊

爱了爱了

go版本

package main

import (
	"encoding/base64"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
)

func WriteSpeech(text, language, outputfile string) bool {
	if !strings.HasSuffix(strings.ToLower(outputfile), ".mp3") {
		outputfile += ".mp3"
	}
	text = strings.Replace(text, ",", "%2C", -1)
	text = url.QueryEscape(text)

	req, err := http.NewRequest("GET", fmt.Sprintf("https://www.google.com/async/translate_tts?&ttsp=tl:%s,txt:%s,spd:1&cs=0&async=_fmt:jspb", language, text), nil)
	if err != nil {
		fmt.Println("Error creating request:", err)
		return false
	}

	req.Header.Add("accept", "*/*")
	req.Header.Add("accept-language", "en-US,en;q=0.9")
	req.Header.Add("priority", "u=1, i")
	req.Header.Add("referer", "https://www.google.com/")
	req.Header.Add("sec-ch-ua", "\"Chromium\";v=\"124\", \"Google Chrome\";v=\"124\", \"Not-A.Brand\";v=\"99\"")
	req.Header.Add("sec-ch-ua-arch", "\"x86\"")
	req.Header.Add("sec-ch-ua-bitness", "\"64\"")
	req.Header.Add("sec-ch-ua-full-version", "\"124.0.6367.208\"")
	req.Header.Add("sec-ch-ua-full-version-list", "\"Chromium\";v=\"124.0.6367.208\", \"Google Chrome\";v=\"124.0.6367.208\", \"Not-A.Brand\";v=\"99.0.0.0\"")
	req.Header.Add("sec-ch-ua-mobile", "?0")
	req.Header.Add("sec-ch-ua-model", "\"\"")
	req.Header.Add("sec-ch-ua-platform", "\"Windows\"")
	req.Header.Add("sec-ch-ua-platform-version", "\"15.0.0\"")
	req.Header.Add("sec-ch-ua-wow64", "?0")
	req.Header.Add("sec-fetch-dest", "empty")
	req.Header.Add("sec-fetch-mode", "cors")
	req.Header.Add("sec-fetch-site", "same-origin")
	req.Header.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36")
	req.Header.Add("x-dos-behavior", "Embed")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error sending request:", err)
		return false
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		fmt.Println("Non-OK HTTP status:", resp.StatusCode)
		return false
	}

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("Error reading response body:", err)
		return false
	}

	responseBody := string(body)
	responseBody = strings.TrimPrefix(responseBody, ")]}'\n{\"translate_tts\":[\"")
	responseBody = strings.TrimSuffix(responseBody, "\"]}")

	data, err := base64.StdEncoding.DecodeString(responseBody)
	if err != nil {
		fmt.Println("Error decoding base64:", err)
		return false
	}

	err = ioutil.WriteFile(outputfile, data, 0644)
	if err != nil {
		fmt.Println("Error writing file:", err)
		return false
	}

	return true
}

func main() {
	// Example usage
	if WriteSpeech("Hello, world!", "en", "output.mp3") {
		fmt.Println("Speech written successfully.")
	} else {
		fmt.Println("Failed to write speech.")
	}
}

感谢分享,微软的tts也有,到吾爱破解上可以搜到,multitts壳+本地voice源。github上还有个大佬做了个,需要联网。

感谢大佬

感谢大佬,点赞,点赞

牛皮,大佬

谢谢佬,爱来自FBI

大佬们,能整个按字幕时间生成音频的吗?比如srt 格式的字幕,我想自动字幕转语音,同时语音与字幕同步。

佬 这个牛呀 另外有没有办法mp3转文字的处理方法呀 非常感谢!!!

有点厉害支持~~

From 软件开发 to 开发调优