non-streaming-speaker-diarization.js
927 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const addon = require('./addon.js');
class OfflineSpeakerDiarization {
constructor(config) {
this.handle = addon.createOfflineSpeakerDiarization(config);
this.config = config;
this.sampleRate = addon.getOfflineSpeakerDiarizationSampleRate(this.handle);
}
/**
* samples is a 1-d float32 array. Each element of the array should be
* in the range [-1, 1].
*
* We assume its sample rate equals to this.sampleRate.
*
* Returns an array of object, where an object is
*
* {
* "start": start_time_in_seconds,
* "end": end_time_in_seconds,
* "speaker": an_integer,
* }
*/
process(samples) {
return addon.offlineSpeakerDiarizationProcess(this.handle, samples);
}
setConfig(config) {
addon.offlineSpeakerDiarizationSetConfig(this.handle, config);
this.config.clustering = config.clustering;
}
}
module.exports = {
OfflineSpeakerDiarization,
}