46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package whisperx
|
|
|
|
import "context"
|
|
|
|
// NoopClient is a deterministic no-op WhisperX adapter.
|
|
type NoopClient struct{}
|
|
|
|
// Transcribe returns the requested output path with placeholder metadata.
|
|
func (n *NoopClient) Transcribe(ctx context.Context, req TranscribeRequest) (TranscribeResult, error) {
|
|
if err := ctx.Err(); err != nil {
|
|
return TranscribeResult{}, err
|
|
}
|
|
return TranscribeResult{
|
|
OutputRawTranscriptPath: req.OutputRawTranscriptPath,
|
|
Metadata: map[string]any{
|
|
"placeholder": true,
|
|
},
|
|
}, nil
|
|
}
|
|
|
|
// FakeClient captures requests and returns deterministic responses for tests.
|
|
type FakeClient struct {
|
|
Requests []TranscribeRequest
|
|
Err error
|
|
Result TranscribeResult
|
|
}
|
|
|
|
// Transcribe records the request and returns either configured error or result.
|
|
func (f *FakeClient) Transcribe(ctx context.Context, req TranscribeRequest) (TranscribeResult, error) {
|
|
if err := ctx.Err(); err != nil {
|
|
return TranscribeResult{}, err
|
|
}
|
|
f.Requests = append(f.Requests, req)
|
|
if f.Err != nil {
|
|
return TranscribeResult{}, f.Err
|
|
}
|
|
res := f.Result
|
|
if res.OutputRawTranscriptPath == "" {
|
|
res.OutputRawTranscriptPath = req.OutputRawTranscriptPath
|
|
}
|
|
if res.Metadata == nil {
|
|
res.Metadata = map[string]any{"fake": true}
|
|
}
|
|
return res, nil
|
|
}
|