Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Transcribe ¶
func Transcribe(ctx context.Context, data []byte, encoding speech.RecognitionConfig_AudioEncoding, sampleRate int32, langLocale string) (string, error)
Transcribe runs audio file agains Google Speech service and returns a top translation alternative
Example ¶
package main import ( "context" "fmt" "io/ioutil" "log" "time" svc "github.com/antontsv/transcribesvc" speech "github.com/google/go-genproto/googleapis/cloud/speech/v1" ) func main() { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() file := "samples/audio.flac" data, err := ioutil.ReadFile(file) if err != nil { log.Fatalf("cannot read sample file: %v", err) } res, err := svc.Transcribe(ctx, data, speech.RecognitionConfig_FLAC, 44100, "en-US") if err != nil { log.Fatalf("cannot transcribe: %v", err) } fmt.Println(res) }
Output: hello Google
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.