Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opus error #12

Merged
merged 1 commit into from
Sep 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bot/discordSR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export default class DiscordSR {
});
const bufferData: Uint8Array[] = [];

audioStream.on("error", (error) => {
this.client.emit("audioStreamError", error);
});

audioStream.on("data", (data) => {
bufferData.push(data);
});
Expand Down
8 changes: 8 additions & 0 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ export declare function voiceJoin(connection: VoiceConnection): void;
* @event
*/
export declare function speech(voiceMessage: VoiceMessage): void;

/**
* Emitted when error occurs during processing audio stream. Usually when someone tries to talk using web version of discord. See https://github.com/discordjs/opus/issues/49
* @asMemberOf DiscordSR
* @param error
* @event
*/
export declare function audioStreamError(error: Error): void;
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
export {
default as DiscordSR,
DiscordSROptions,
SpeechRecognition as speechRecognition,
SpeechRecognitionOptions,
DiscordSROptions,
} from "./bot/discordSR";
export { speech, voiceJoin } from "./events";
export { default as VoiceMessage } from "./bot/voiceMessage";
export { audioStreamError, speech, voiceJoin } from "./events";
export {
resolveSpeechWithGoogleSpeechV2,
GoogleSpeechV2Options,
resolveSpeechWithGoogleSpeechV2,
} from "./speechRecognition/googleV2";
export {
resolveSpeechWithWITAI,
WitaiOptions as WITAIOptions,
} from "./speechRecognition/witAI";
export { wavUrlToBuffer, getDurationFromMonoBuffer } from "./utils/audio";
export { getDurationFromMonoBuffer, wavUrlToBuffer } from "./utils/audio";