package httpapi import ( "context" "speech-learning-api/internal/domain" "speech-learning-api/internal/services" "strings" ) // Explicit local fixture, not a claim of a real Azure measurement. type bankFixtureSpeech struct{} func (bankFixtureSpeech) AssessPronunciation(_ context.Context, in services.PronunciationInput) (domain.PronunciationResult, error) { return domain.PronunciationResult{Provider: "azure", RecognizedText: in.TargetText, OverallScore: 90, AccuracyScore: 90}, nil } func (bankFixtureSpeech) Transcribe(context.Context, []byte, string, string) (string, error) { return "I have got a brother.", nil } func (bankFixtureSpeech) Synthesize(context.Context, string, string, string) ([]byte, string, error) { return []byte("fixture mp3"), "audio/mpeg", nil } func (bankFixtureSpeech) SynthesizeExercise(context.Context, string, string, string, string, string) ([]byte, string, error) { return []byte("fixture mp3"), "audio/mpeg", nil } // Named fixtures intentionally simulate known measurements; they never call Azure. type statisticalFixtureSpeech struct{ bankFixtureSpeech } func (statisticalFixtureSpeech) AssessPronunciation(_ context.Context, in services.PronunciationInput) (domain.PronunciationResult, error) { result := domain.PronunciationResult{Provider: "azure", Locale: in.Locale, Alphabet: "IPA", Method: "scripted", MeasurementVersion: "test-fixture", RecognizedText: in.TargetText, OverallScore: 80, AccuracyScore: 80} for _, token := range strings.Fields(in.TargetText) { word := strings.ToLower(strings.Trim(token, ".,!?")) w := domain.WordScore{Word: word, Accuracy: 90, Highlight: "good"} if word == "cat" || word == "cup" || word == "school" { w.Accuracy = 40 w.Highlight = "weak" w.PhonemeScores = []domain.PhonemeScore{{Phoneme: "k", Accuracy: 30, Highlight: "weak"}} } result.WordScores = append(result.WordScores, w) } return result, nil }