omar1232 commited on
Commit
325b963
·
verified ·
1 Parent(s): 1cb5b8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -14
app.py CHANGED
@@ -4,20 +4,7 @@ from pydub import AudioSegment
4
  import tempfile
5
  from langdetect import detect
6
  import os
7
- import asyncio
8
- from telegram import Update
9
- from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes
10
-
11
- # Telegram bot token (to be set via Hugging Face Space secrets)
12
- TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
13
-
14
- # Process audio and transcribe
15
- def process_audio(audio_input):
16
- recognizer = sr.Recognizer()
17
-
18
- # Convert all audio inputs to WAV format
19
- with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
20
- if isinstance(audio_input, tuple): # Recorded audio (sample_rate, numpy_array)
21
  sample_rate, audio_data = audio_input
22
  AudioSegment(audio_data, sample_rate=sample_rate, frame_rate=sample_rate, channels=1).export(temp_file.name, format="wav")
23
  else: # Uploaded audio file (file path or Telegram file)
 
4
  import tempfile
5
  from langdetect import detect
6
  import os
7
+ import asynciostance(audio_input, tuple): # Recorded audio (sample_rate, numpy_array)
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  sample_rate, audio_data = audio_input
9
  AudioSegment(audio_data, sample_rate=sample_rate, frame_rate=sample_rate, channels=1).export(temp_file.name, format="wav")
10
  else: # Uploaded audio file (file path or Telegram file)