MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / sendAudioBuffer

Method sendAudioBuffer

outdated/gemini/gemini.ts:281–305  ·  view source on GitHub ↗
(
    msg: Api.Message,
    audioData: Buffer,
    caption: string,
    mimeType?: string
  )

Source from the content-addressed store, hash-verified

279 }
280
281 static async sendAudioBuffer(
282 msg: Api.Message,
283 audioData: Buffer,
284 caption: string,
285 mimeType?: string
286 ): Promise<void> {
287 let processedAudio = audioData;
288 if (mimeType && mimeType.includes('L16') && mimeType.includes('pcm')) {
289 processedAudio = this.convertToWav(audioData, mimeType);
290 }
291 const audioFile = Object.assign(processedAudio, {
292 name: 'gemini.ogg'
293 });
294
295 await msg.client?.sendFile(msg.peerId, {
296 file: audioFile,
297 caption,
298 parseMode: "html",
299 replyTo: msg.id,
300 attributes: [new Api.DocumentAttributeAudio({
301 duration: 0,
302 voice: true
303 })]
304 });
305 }
306
307 static convertToWav(rawData: string | Buffer, mimeType: string): Buffer {
308 const options = this.parseMimeType(mimeType);

Callers 1

handleQuestionWithAudioFunction · 0.80

Calls 1

convertToWavMethod · 0.95

Tested by

no test coverage detected