feat: upload audio, get a private Swedish transcript, discuss it (#33, ADR-033) #39
@@ -0,0 +1,49 @@
|
||||
package transcribe_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"git.d-ma.be/mathias/tapir/internal/adapters/transcribe"
|
||||
)
|
||||
|
||||
// TestGateway_LiveGateway is an opt-in check against the REAL gateway, because
|
||||
// the httptest fake above can only prove what we think the gateway accepts. It
|
||||
// is skipped unless TAPIR_LIVE_WAV names a 16 kHz mono WAV and the gateway
|
||||
// coordinates are set:
|
||||
//
|
||||
// TAPIR_LIVE_WAV=/path/a.wav TAPIR_LIVE_GATEWAY_URL=http://koala:30401/v1 \
|
||||
// TAPIR_LIVE_MODEL=iguana/kb-whisper op run --env-file ~/.op-env -- \
|
||||
// go test ./internal/adapters/transcribe -run LiveGateway -v
|
||||
//
|
||||
// Use SYNTHETIC audio only: this repo is public and the gateway may be a cloud
|
||||
// endpoint (#33).
|
||||
func TestGateway_LiveGateway(t *testing.T) {
|
||||
wav := os.Getenv("TAPIR_LIVE_WAV")
|
||||
url := os.Getenv("TAPIR_LIVE_GATEWAY_URL")
|
||||
if wav == "" || url == "" {
|
||||
t.Skip("set TAPIR_LIVE_WAV and TAPIR_LIVE_GATEWAY_URL to run against the real gateway")
|
||||
}
|
||||
model := os.Getenv("TAPIR_LIVE_MODEL")
|
||||
if model == "" {
|
||||
model = "iguana/kb-whisper"
|
||||
}
|
||||
key := os.Getenv("LITELLM_MASTER_KEY")
|
||||
require.NotEmpty(t, key, "LITELLM_MASTER_KEY must be set (via op run)")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 25*time.Minute)
|
||||
defer cancel()
|
||||
got, err := transcribe.NewGateway(url, key, model, &http.Client{}).Transcribe(ctx, wav)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, got.Text)
|
||||
assert.NotEmpty(t, got.Segments)
|
||||
assert.Equal(t, model, got.Endpoint)
|
||||
t.Logf("endpoint=%s audio_s=%.1f segments=%d chars=%d", got.Endpoint, got.AudioSeconds, len(got.Segments), len(got.Text))
|
||||
}
|
||||
Reference in New Issue
Block a user