edge-tts

module
v0.0.0-...-d7395f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0

README

edge-tts

Use Microsoft Edge's online text-to-speech service from go WITHOUT needing Microsoft Edge or Windows or an API key

Getting started

go get -u github.com/xiaolibuzai-ovo/edge-tts

Example

Text-to-Speech
package main

import (
	edgeTTS "github.com/xiaolibuzai-ovo/edge-tts/pkg/wrapper"
	"golang.org/x/net/context"
	"io"
	"os"
)

func main() {
	tts := edgeTTS.NewEdgeTTS()
	voice := "zh-CN-XiaoxiaoNeural"
	speech, err := tts.TextToSpeech(context.Background(), "hello,world", voice)
	if err != nil {
		return
	}

	// speech is io.ReaderCloser
	// such as
	filePath := "./output.mp3"
	file, err := os.Create(filePath)
	if err != nil {
		return
	}
	defer file.Close()
	io.Copy(file, speech)
}
voice-list
package main

import (
	"fmt"
	edgeTTS "github.com/xiaolibuzai-ovo/edge-tts/pkg/wrapper"
	"golang.org/x/net/context"
)

func main() {
	tts := edgeTTS.NewEdgeTTS()
	voiceList, err := tts.VoiceList(context.Background())
	if err != nil {
		return
	}

	fmt.Println(voiceList)
}

refer

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL