Documentation ¶
Overview ¶
Package goEagi of vosk.go provides a simplified interface for calling Vosk Server's speech to text service. It provides flexibility to the callers and allow them to set their desired configuration.
Index ¶
- func AudioStreaming(ctx context.Context) <-chan AudioResult
- func ComputeAmplitude(sample []byte) (float64, error)
- func GenerateAudio(sample []byte, audioDirectory string, audioName string) (string, error)
- type AudioResult
- type Eagi
- type GoogleResult
- type GoogleService
- type Vad
- type VadResult
- type VoskResult
- type VoskService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AudioStreaming ¶
func AudioStreaming(ctx context.Context) <-chan AudioResult
AudioStreaming launches a new goroutine for audio streaming via file descriptor 3.
func ComputeAmplitude ¶
ComputeAmplitude analyzes the amplitude of a sample slice of bytes.
func GenerateAudio ¶
GenerateAudio writes a sample slice of bytes into an audio file. It returns a location path of an audio which passed in the function parameters. Please note that only wav extension is supported.
Types ¶
type AudioResult ¶
type GoogleResult ¶
type GoogleService ¶
type GoogleService struct {
// contains filtered or unexported fields
}
GoogleService provides information to Google Speech Recognizer and speech to text methods.
func NewGoogleService ¶
func NewGoogleService(privateKeyPath string, languageCode string, speechContext []string) (*GoogleService, error)
NewGoogleService is a constructor of GoogleService, it takes a privateKeyPath to set it in environment with key GOOGLE_APPLICATION_CREDENTIALS, a languageCode, example ["en-GB", "en-US", "ch", ...], see (https://cloud.google.com/speech-to-text/docs/languages), and a speech context, see (https://cloud.google.com/speech-to-text/docs/speech-adaptation).
func (*GoogleService) SpeechToTextResponse ¶
func (g *GoogleService) SpeechToTextResponse(ctx context.Context) <-chan GoogleResult
SpeechToTextResponse sends the transcription response from Google's SpeechToText.
func (*GoogleService) StartStreaming ¶
func (g *GoogleService) StartStreaming(ctx context.Context, stream <-chan []byte) <-chan error
StartStreaming takes a reading channel of audio stream and sends it as a gRPC request to Google service through the initialized client. Caller should run it in a goroutine.
type Vad ¶
type Vad struct {
AmplitudeDetectionThreshold float64
}
type VoskResult ¶
type VoskResult struct { Result []struct { Conf float64 End float64 Start float64 Word string } Text string Partial string }
VoskResult represents a partial o complete response from vosk server
type VoskService ¶
type VoskService struct { PhraseList []string `json:"phrase_list"` Words bool `json:"words"` Client *websocket.Conn `json:"-"` // contains filtered or unexported fields }
VoskService provides information to Vosk Speech Recognizer as well as methods on calling speech to text.
func NewVoskService ¶
func NewVoskService(host string, port string, phraseList []string) (*VoskService, error)
NewVoskService is a constructor of VoskService, @param
func (*VoskService) Close ¶
func (v *VoskService) Close() error
Close closses vosk service connection
func (*VoskService) SpeechToTextResponse ¶
func (v *VoskService) SpeechToTextResponse(ctx context.Context) <-chan VoskResult
SpeechToTextResponse sends the transcription response from Vosk's SpeechToText.
func (*VoskService) StartStreaming ¶
func (v *VoskService) StartStreaming(ctx context.Context, stream <-chan []byte) <-chan error
StartStreaming takes a reading channel of audio stream and sends it as a gRPC request to Vosk service through the initialized client. Caller should run it in a goroutine.