Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
albho committed Feb 27, 2024
1 parent 3c12957 commit bc9dc9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion binding/nodejs/src/eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class EagleProfiler {
* 16-bit linearly-encoded. EagleProfiler operates on single-channel audio.
* @return {EnrollProgress} The percentage of completeness of the speaker enrollment process along with the feedback code
* corresponding to the last enrollment attempt:
* - `AUDIO_OK`: The audio is good for enrollment.
* - `NONE`: The audio is good for enrollment.
* - `AUDIO_TOO_SHORT`: Audio length is insufficient for enrollment,
* i.e. it is shorter than`.min_enroll_samples`.
* - `UNKNOWN_SPEAKER`: There is another speaker in the audio that is different from the speaker
Expand Down
9 changes: 7 additions & 2 deletions demo/nodejs/file.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ async function fileDemo() {
console.error(
"Audio file did not meet requirements. Wave file must be 16KHz, 16-bit, linear PCM (mono)."
);
eagleProfiler?.release();
process.exit();
}

let audioData = [];
Expand Down Expand Up @@ -157,7 +159,7 @@ async function fileDemo() {

if (enrollPercentage < 100) {
console.error(`Failed to create speaker profile. Insufficient enrollment percentage: ${enrollPercentage.toFixed(2)}%. Please add more audio files for enrollment.`);
eagle.release();
eagleProfiler?.release();
process.exit();
} else if (enrollPercentage === 100) {
const speakerProfile = eagleProfiler.export();
Expand Down Expand Up @@ -213,13 +215,16 @@ async function fileDemo() {
} catch (error) {
console.error(`Exception trying to read file as wave format: ${testAudioPath}`);
console.error(error);
return;
eagle?.release();
process.exit();
}

if (!checkWaveFile(inputWaveFile, eagle.sampleRate)) {
console.error(
"Audio file did not meet requirements. Wave file must be 16KHz, 16-bit, linear PCM (mono)."
);
eagle?.release();
process.exit();
}

let frames = getInt16Frames(inputWaveFile, eagle.frameLength);
Expand Down
2 changes: 1 addition & 1 deletion demo/nodejs/mic.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ async function micDemo() {
printResults(scores, speakerLabels);
}

process.stdout.write("\nStopping...");
process.stdout.write("\nStopping...\n");
} catch (e) {
if (e instanceof EagleErrors.EagleActivationLimitReachedError) {
console.error(`AccessKey '${accessKey}' has reached it's processing limit.`);
Expand Down

0 comments on commit bc9dc9c

Please sign in to comment.