add support for speech-to-text endpoint (#10)

This commit is contained in:
Jose Ramirez
2025-03-03 11:16:04 -08:00
committed by GitHub
parent db0a2e1760
commit 93af72dc7c
4 changed files with 227 additions and 0 deletions

3
cmd/transcribe/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.mp3
main
transcribe

34
cmd/transcribe/main.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/taigrr/elevenlabs/client"
"github.com/taigrr/elevenlabs/client/types"
)
func main() {
ctx := context.Background()
client := client.New(os.Getenv("XI_API_KEY"))
filePath := os.Args[1]
resp, err := client.ConvertSpeechToText(ctx, filePath, types.SpeechToTextRequest{
ModelID: types.SpeehToTextModelScribeV1,
TimestampsGranularity: types.TimestampsGranularityWord,
Diarize: true,
})
if err != nil {
panic(err)
}
bytes, err := json.Marshal(resp)
if err != nil {
panic(err)
}
fmt.Println(string(bytes))
}