TLSphinx是一个围绕着Pocketsphinx的封装器,一个基于CMUSphinx的便携库,允许应用程序执行的语音识别而无需将音频移出设备。
示例:
import TLSphinxlet hmm = ... // Path to the acustic modellet lm = ... // Path to the languaje modellet dict = ... // Path to the languaje dictionaryif let config = Config(args: ("-hmm", hmm), ("-lm", lm), ("-dict", dict)) { if let decoder = Decoder(config:config) { let audioFile = ... // Path to an audio file decoder.decodeSpeechAtPath(audioFile) { if let hyp: Hypotesis = $0 { // Print the decoder text and score println("Text: \(hyp.text) - Score: \(hyp.score)") } else { // Can't decode any speech because an error } } } else { // Handle Decoder() fail }} else { // Handle Config() fail }
评论