Advertisement
samiroexpikachu

Transcribe

Mar 13th, 2024 (edited)
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require("axios");
  2.  
  3. const config = {
  4.   name: "transcribe",
  5.   aliases: ["ts"],
  6.   version: "1.1",
  7.   author: "Samir Œ",
  8.   countDown: 10,
  9.   role: 0,
  10.   shortDescription: {
  11.     en: "Converts speech into text."
  12.   },
  13.   longDescription: {
  14.     en: "Converts speech into text using the Google Cloud Speech-to-Text API."
  15.   },
  16.   category: "AI",
  17.   guide: {
  18.     en: "{pn} reply to an audio/video"
  19.   }
  20. };
  21.  
  22. const onStart = async function({ event, api, message }) {
  23.   try {
  24.     if (!event.messageReply.attachments || event.messageReply.attachments.length === 0) {
  25.       return message.reply('Please reply to an audio or video.');
  26.     }
  27.  
  28.     const link = event.messageReply.attachments[0].url;
  29.     const response = await axios.get(`https://apis-samir.onrender.com/transcribe?url=${encodeURIComponent(link)}`);
  30.     const text = response.data.transcript;
  31.  
  32.     if (text) {
  33.       message.reply({
  34.         body: text
  35.       });
  36.     } else {
  37.       message.reply("Failed to transcribe the audio or video.");
  38.     }
  39.   } catch (error) {
  40.     console.error(error);
  41.     message.reply("An error occurred while processing the request.");
  42.   }
  43. };
  44.  
  45. module.exports = {
  46.   config,
  47.   onStart
  48. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement