mirror of
https://github.com/taigrr/elevenlabs.git
synced 2026-04-02 03:08:57 -07:00
add support for speech-to-text endpoint (#10)
This commit is contained in:
3
cmd/transcribe/.gitignore
vendored
Normal file
3
cmd/transcribe/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*.mp3
|
||||
main
|
||||
transcribe
|
||||
34
cmd/transcribe/main.go
Normal file
34
cmd/transcribe/main.go
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user