Discord Speech Recognition
    Preparing search index...

    Function addSpeechEvent

    • Main function, use this to add new events to present discord.Client

      Defaults uses en-US language and google speech v2 api with generic key, that should be used for personal or testing purposes only, as it may be revoked by Google at any time.
      You can obtain your own API key here http://www.chromium.org/developers/how-tos/api-keys.
      See python speech recognition package for more details.


      Example usage:

      const client = new Client({
      intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates],
      });
      // You can modify speechOptions object to change how things work
      const speechOptions = addSpeechEvent(client, { lang: "pl-PL" });

      Type Parameters

      Parameters

      Returns {
          group?: string;
          ignoreBots?: boolean;
          key?: string;
          lang?: string;
          maximalVoiceMessageDuration?: number;
          minimalVoiceMessageDuration?: number;
          profanityFilter?: boolean;
          shouldProcessSpeech?: (user: User, connection: VoiceConnection) => boolean;
          silenceDuration?: number;
          speechRecognition?:
              | (
                  (
                      audioBuffer: Buffer,
                      options?: GoogleSpeechV2Options,
                  ) => Promise<string>
              )
              | T;
      }

      • Optionalgroup?: string

        Group identifier, use it if you pass group to joinVoiceChannel https://discord.js.org/docs/packages/voice/main/JoinVoiceChannelOptions:Interface#group

      • OptionalignoreBots?: boolean

        Don't listen to other bots. Defaults to true

      • Optionalkey?: string
      • Optionallang?: string

        Language of the speech, for example en-US or pl-PL. Defaults to en-US

      • OptionalmaximalVoiceMessageDuration?: number

        Maximal length of a single voice message, in seconds. Longer speech is split into multiple voice messages.

        Defaults to 19, because Google Speech and wit.ai reject longer audio. Raise it if your speech recognition function can handle more.

      • OptionalminimalVoiceMessageDuration?: number

        Minimal length of voice message that will be processed, in seconds. Defaults to 1

      • OptionalprofanityFilter?: boolean

        Replaces vulgar words with asterisks. Defaults to true

      • OptionalshouldProcessSpeech?: (user: User, connection: VoiceConnection) => boolean

        Custom handler to decide whether to recognize speech. It is called when the user starts speaking: if it returns false, the audio isn't recorded or sent anywhere.

      • OptionalsilenceDuration?: number

        How long the user has to be silent before the voice message ends, in milliseconds. Defaults to 300

      • OptionalspeechRecognition?: ((audioBuffer: Buffer, options?: GoogleSpeechV2Options) => Promise<string>) | T