Giter Club home page Giter Club logo

aliyun-voice's Introduction

阿里云 智能语音识别 SDK

GO 语言版本


Install

go get https://github.com/huyinghuan/aliyun-voice

TTS 【语音合成服务】

package:

"github.com/huyinghuan/aliyun-voice/tts"

tts.GetAuth(accessID string, accessKey string):*Auth

阿里云认证。

  auth := tts.GetAuth(ALIYUNACCESSID, ALIYUNACCESSKEY)

auth.GetVoice(text string):([]byte, error)

获取语音文件字节数组,或抛出错误。

auth.SaveVoice(text string, dist string):error

存储语音文件到指定目录【dist】,或抛出错误。

auth.TTSConfig

设置语音文件属性,参考:https://help.aliyun.com/document_detail/52793.html?spm=5176.doc30422.6.587.Z6Muvv

auth.TTSConfig = &auth.TTS{
  EncodeType            string
	VoiceName             string
	Volume                int //0-100
	SampleRate            int //8000 or 16000
	SpeechRate            int //-500-500
	PitchRate             int //-500-500
	TssNus                int // 0 or 1
	BackgroundMusicID     int // 0 or 1
	BackgroundMusicOffset int // default 0,
	BackgroundMusicVolume int //default 50, 0-100
}

or

auth.TTSConfig.EncodeType = xxxxx 
auth.TTSConfig.Volume = 90
...

Test

填写 tts/index_test.goALIYUNACCESSIDALIYUNACCESSKEY

go test aliyun-voice/tts -v

Example

package main

import (
	"log"
	"os/user"
	"path/filepath"

	"github.com/huyinghuan/aliyun-voice/tts"
)

func main() {

	//ALIYUNACCESSID 阿里云 access_id
	var ALIYUNACCESSID = "Your aliyun access_id"

	//ALIYUNACCESSKEY 阿里云 access_key
	var ALIYUNACCESSKEY = "Your aliyun access_key"
	myself, _ := user.Current()
	voiceFile := filepath.Join(myself.HomeDir, "Desktop", "b.mp3")
	auth := tts.GetAuth(ALIYUNACCESSID, ALIYUNACCESSKEY)
	if err := auth.SaveVoice("窗前明月光,地上鞋一双。", voiceFile); err != nil {
		log.Fatalln(err)
	}
}

aliyun-voice's People

Contributors

huyinghuan avatar

Watchers

James Cloos avatar jiaji avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.