Phonembewertung speichern und anzeigen
Azure-Phonemwerte in Versuchen sichern, schwache Laute im Fortschritt und Flowise-Kontext auswerten und die Web-Anzeige ergänzen. README dokumentiert Datenfluss, Betrieb und Grenzen der Funktion.
This commit is contained in:
@@ -157,7 +157,11 @@ type azurePronunciationResponse struct {
|
||||
ErrorType string `json:"ErrorType"`
|
||||
} `json:"PronunciationAssessment"`
|
||||
Phonemes []struct {
|
||||
Phoneme string `json:"Phoneme"`
|
||||
Phoneme string `json:"Phoneme"`
|
||||
AccuracyScore *float64 `json:"AccuracyScore"`
|
||||
PronunciationAssessment struct {
|
||||
AccuracyScore *float64 `json:"AccuracyScore"`
|
||||
} `json:"PronunciationAssessment"`
|
||||
} `json:"Phonemes"`
|
||||
} `json:"Words"`
|
||||
} `json:"NBest"`
|
||||
@@ -183,18 +187,29 @@ func parseAzurePronunciation(body []byte) (domain.PronunciationResult, error) {
|
||||
}
|
||||
for _, word := range best.Words {
|
||||
phonemes := make([]string, 0, len(word.Phonemes))
|
||||
phonemeScores := make([]domain.PhonemeScore, 0, len(word.Phonemes))
|
||||
for _, phoneme := range word.Phonemes {
|
||||
if phoneme.Phoneme != "" {
|
||||
phonemes = append(phonemes, phoneme.Phoneme)
|
||||
accuracy := phoneme.PronunciationAssessment.AccuracyScore
|
||||
if accuracy == nil {
|
||||
accuracy = phoneme.AccuracyScore
|
||||
}
|
||||
if accuracy != nil {
|
||||
phonemeScores = append(phonemeScores, domain.PhonemeScore{
|
||||
Phoneme: phoneme.Phoneme, Accuracy: *accuracy, Highlight: highlightFor(*accuracy),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
score := firstScore(word.AccuracyScore, word.PronunciationAssessment.AccuracyScore)
|
||||
result.WordScores = append(result.WordScores, domain.WordScore{
|
||||
Word: word.Word,
|
||||
Accuracy: score,
|
||||
ErrorType: firstNonEmpty(word.PronunciationAssessment.ErrorType, word.ErrorType),
|
||||
Phonemes: phonemes,
|
||||
Highlight: highlightFor(score),
|
||||
Word: word.Word,
|
||||
Accuracy: score,
|
||||
ErrorType: firstNonEmpty(word.PronunciationAssessment.ErrorType, word.ErrorType),
|
||||
Phonemes: phonemes,
|
||||
PhonemeScores: phonemeScores,
|
||||
Highlight: highlightFor(score),
|
||||
})
|
||||
}
|
||||
return result, nil
|
||||
@@ -238,7 +253,7 @@ func highlightFor(score float64) string {
|
||||
switch {
|
||||
case score >= 85:
|
||||
return "good"
|
||||
case score >= 70:
|
||||
case score >= 75:
|
||||
return "ok"
|
||||
default:
|
||||
return "weak"
|
||||
|
||||
Reference in New Issue
Block a user