(
msg: Api.Message,
audioData: Buffer,
caption: string,
mimeType?: string
)
| 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); |
no test coverage detected