amivoice

package module
v0.0.0-...-acb66b2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 9 Imported by: 0

README

amivoice-go

PkgGoDev Go Report Card

AmiVoice Cloud PlatformのGoライブラリです

ライブラリとして利用

Websocket音声認識APIにのみ対応しています。

単発で音声ファイルを変換するサンプル

Aイベントの結果のみを利用します。 実行には設定ファイル(setting.yamlが必要です)

go get github.com/juntaki/amivoice-go/cmd/transcribe
transcribe test.wav

リアルタイムでの字幕生成サンプル

AイベントとUイベントを利用してGUIで字幕をリアルタイムに生成します。 マルチプラットフォームで動作します。Linux/Macで確認済み。 実行には設定ファイル(setting.yamlが必要です)

go get github.com/juntaki/amivoice-go/cmd/caption
caption

setting.yamlの書式

詳細はサンプルファイルを参照してください。 実行時のワーキングディレクトリに存在している必要があります。

app_key: <APP_KEY>
audio_format: 16k
grammar_file: -a-general

Documentation

Index

Constants

View Source
const (
	GammarFileGeneral      GrammarFile = "-a-general"
	GammarFileMedgeneral               = "-a-medgeneral"
	GammarFileBizmrreport              = "-a-bizmrreport"
	GammarFileBizfinance               = "-a-bizfinance"
	GammarFileMedcare                  = "-a-medcare"
	GammarFileMedkarte                 = "-a-medkarte"
	GammarFileMedpharmacy              = "-a-medpharmacy"
	GammarFileBizinsurance             = "-a-bizinsurance"
	GammarFileMeeting                  = "-a-meeting"
)
View Source
const (
	AudioFormatLSB8k  AudioFormat = "lsb8k"
	AudioFormatMSB8k              = "msb8k"
	AudioFormatLSB11k             = "lsb11k"
	AudioFormatMSB11k             = "msb11k"
	AudioFormatLSB16k             = "lsb16k"
	AudioFormatMSB16k             = "msb16k"
	AudioFormatLSB22k             = "lsb22k"
	AudioFormatMSB22k             = "msb22k"
	AudioFormatMuLaw              = "mulaw"
	AudioFormatALaw               = "alaw"
	AudioFormat8k                 = "8k"
	AudioFormat16k                = "16k"
)

Variables

View Source
var (
	ErrConnClosed        = errors.New("read from closed connection")
	ErrEResponseReceived = errors.New("e response received")
)

Functions

This section is empty.

Types

type AEvent

type AEvent struct {
	Results []struct {
		Tokens []struct {
			Written    string  `json:"written"`
			Confidence float64 `json:"confidence"`
			StartTime  int     `json:"starttime"`
			EndTime    int     `json:"endtime"`
			Spoken     string  `json:"spoken"`
		} `json:"tokens"`
		Confidence float64       `json:"confidence"`
		StartTime  int           `json:"starttime"`
		EndTime    int           `json:"endtime"`
		Tags       []interface{} `json:"tags"`
		RuleName   string        `json:"rulename"`
		Text       string        `json:"text"`
	} `json:"results"`
	UtteranceID string `json:"utteranceid"`
	Text        string `json:"text"`
	Code        string `json:"code"`
	Message     string `json:"message"`
}

func (*AEvent) IsSuccess

func (a *AEvent) IsSuccess() bool

type AudioFormat

type AudioFormat string

type Conn

type Conn struct {
	Conn     *websocket.Conn
	AppKey   string
	IsClosed bool
}

func NewConnection

func NewConnection(appKey string, noLog bool) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) CollectFinalResult

func (c *Conn) CollectFinalResult(w io.Writer) error

func (*Conn) CollectOneResult

func (c *Conn) CollectOneResult(fixedResult chan<- *AEvent, progressResult chan<- *UEvent, notification chan<- string) error

func (*Conn) CollectResult

func (c *Conn) CollectResult(fixedResult chan<- *AEvent, progressResult chan<- *UEvent, notification chan<- string) error

func (*Conn) Recognize

func (c *Conn) Recognize(i *RecognitionConfig) error

func (*Conn) Transcribe

func (c *Conn) Transcribe(i *RecognitionConfig, w io.Writer) error

type GrammarFile

type GrammarFile string

type ProfileWord

type ProfileWord struct {
	Notation string
	Sound    string
}

func (*ProfileWord) String

func (p *ProfileWord) String() string

type RecognitionConfig

type RecognitionConfig struct {
	AudioFormat      AudioFormat
	GrammarFileNames GrammarFile
	ProfileID        string
	ProfileWords     []ProfileWord
	Data             io.Reader
}

type UEvent

type UEvent struct {
	Results []struct {
		Tokens []struct {
			Written string `json:"written"`
		} `json:"tokens"`
		Text string `json:"text"`
	} `json:"results"`
	Text string `json:"text"`
}

Directories

Path Synopsis
cmd
lib

Jump to

Keyboard shortcuts

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