Skip to content

yosssi/go-voicetext

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

go-voicetext - VoiceText Web API クライアント

wercker status Coverage Status GoDoc

概要

go-voicetextはGo言語向けのVoiceText Web APIクライアントです。

インストール

go get -u github.com/yosssi/go-voicetext

実装例

go-voicetextを用いた簡単な実装例を以下に記載します。

package main

import (
	"fmt"
	"os"

	"github.com/yosssi/go-voicetext"
)

func main() {
	c := voicetext.NewClient(os.Getenv("VOICETEXT_API_KEY"), nil)
	result, err := c.TTS("Hello.", nil)
	if err != nil {
		panic(err)
	}

	if result.ErrMsg != nil {
		fmt.Println(result.ErrMsg)
		return
	}

	f, err := os.Create("hello.wav")
	if err != nil {
		panic(err)
	}

	defer func() {
		if err := f.Close(); err != nil {
			panic(err)
		}
	}()

	if _, err := f.Write(result.Sound); err != nil {
		panic(err)
	}
}

以下のように、TTSメソッドにオプションの設定を指定することができます。

package main

import (
	"fmt"
	"os"

	"github.com/yosssi/go-voicetext"
)

func main() {
	c := voicetext.NewClient(os.Getenv("VOICETEXT_API_KEY"), nil)
	result, err := c.TTS("Hello.", &voicetext.TTSOptions{
		Speaker:      voicetext.SpeakerHaruka,
		Emotion:      voicetext.EmotionHappiness,
		EmotionLevel: "2",
		Pitch:        90,
		Speed:        110,
		Volume:       200,
	})
	if err != nil {
		panic(err)
	}

	if result.ErrMsg != nil {
		fmt.Println(result.ErrMsg)
		return
	}

	f, err := os.Create("hello.wav")
	if err != nil {
		panic(err)
	}

	defer func() {
		if err := f.Close(); err != nil {
			panic(err)
		}
	}()

	if _, err := f.Write(result.Sound); err != nil {
		panic(err)
	}
}

ドキュメント

About

Go言語向けVoiceText Web APIクライアント

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages