https://github.com/codycollier/wer
A word error rate util for golang
https://github.com/codycollier/wer
asr speech-recognition speech-to-text word-error-rate
Last synced: 7 months ago
JSON representation
A word error rate util for golang
- Host: GitHub
- URL: https://github.com/codycollier/wer
- Owner: codycollier
- License: apache-2.0
- Created: 2020-11-13T05:19:14.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-14T00:02:54.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T05:21:54.036Z (over 1 year ago)
- Topics: asr, speech-recognition, speech-to-text, word-error-rate
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Word Error Rate (wer)
`wer` is a golang package which provides a function for calculating word error rate and word accuracy. It expects a pair of pre-tokenized and optionally pre-processed strings.
References:
* https://martin-thoma.com/word-error-rate-calculation/
* https://en.wikipedia.org/wiki/Word_error_rate## Example Usage
```
package mainimport (
"fmt"
"strings""github.com/codycollier/wer"
)func main() {
// strings to be evaluated
knownGoodTranscript := "The quick brown fox jumps over the lazy dog"
candidateTranscript := "the slow grey snail jumps over the lazy cat"// optionally lowercase / pre-process
knownGoodTranscript = strings.ToLower(knownGoodTranscript)
candidateTranscript = strings.ToLower(candidateTranscript)// convert to a list of words/tokens
reference := strings.Split(knownGoodTranscript, " ")
candidate := strings.Split(candidateTranscript, " ")// compare
wer, wacc := wer.WER(reference, candidate)fmt.Printf("reference: %s\n", reference)
fmt.Printf("candidate: %s\n", candidate)
fmt.Printf("word error rate: %v\n", wer)
fmt.Printf("word accuracy: %v\n", wacc)}
``````
[host]$ go run example/example.go
reference: [the quick brown fox jumps over the lazy dog]
candidate: [the slow grey snail jumps over the lazy cat]
word error rate: 0.4444444444444444
word accuracy: 0.5555555555555556
```