pocketsphinx:作为单一结果返回长话语

时间:2016-06-28 21:57:03

标签: speech-recognition speech-to-text cmusphinx pocketsphinx

分析大约1分钟的声音文件时,pocketsphinx会将文件分成多个结果。有没有办法改变代码以返回单个话语?我正在使用基于import {Component} from 'angular2/core'; import * as Rx from 'rxjs/Rx' @Component({ selector: 'a-webapp', template:` <div> <h2>{{name}}</h2> <button (click)="addToArray()">Add</button> <button (click)="resetArray()">Reset</button> <ul> <li *ngFor="let item of latest$ | async">{{ item | json }}</li> </ul> {{ data | json }} </div> ` }) export class AppComponent { data = ["one", "two", "three"] data$: Rx.Observable<Array<string>>; latest$: Rx.Observable<Array<string>>; constructor() {} ngOnInit() { this.data$ = Rx.Observable.interval(10).concatMap(y => { return Rx.Observable.of(this.data) }) this.latest$ = Rx.Observable.combineLatest(this.data$, (data) => { return data.map(d => { return d + " is a number" }) }) } addToArray() { this.data.push('more numbers') } resetArray() { this.data = ["one", "two", "three"] } } 的代码。

continuous_test.py

1 个答案:

答案 0 :(得分:-1)

result = "" 

in_speech_bf = False
decoder.start_utt()
while True:
    buf = stream.read(1024)
    if buf:
        decoder.process_raw(buf, False, False)
        if decoder.get_in_speech() != in_speech_bf:
            in_speech_bf = decoder.get_in_speech()
            if not in_speech_bf:
                decoder.end_utt()
                result = result + decoder.hyp().hypstr
                decoder.start_utt()
    else:
        break
decoder.end_utt()

return result