rasulbrur commited on
Commit
72801e6
·
verified ·
1 Parent(s): 7ba047e

Update app.py

Browse files

Updated audio dir

Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -23,7 +23,6 @@ app.mount("/static", StaticFiles(directory="static"), name="static")
23
  # Set up templates
24
  templates = Jinja2Templates(directory="templates")
25
 
26
- root_dir = "./voice"
27
 
28
  # Vosk model path
29
  vosk_model_path = "./vosk-model-small-en-us-0.15"
@@ -63,7 +62,7 @@ async def upload_audio(request: Request, audio_file: UploadFile = File(...)):
63
  try:
64
  with tempfile.TemporaryDirectory() as temp_dir:
65
  # Save the uploaded file (could be WebM, OGG, etc.)
66
- input_file_path = os.path.join(root_dir, "input_audio")
67
  with open(input_file_path, "wb") as buffer:
68
  shutil.copyfileobj(audio_file.file, buffer)
69
  file_size = os.path.getsize(input_file_path) if os.path.exists(input_file_path) else 0
@@ -78,7 +77,7 @@ async def upload_audio(request: Request, audio_file: UploadFile = File(...)):
78
  })
79
 
80
  # Convert to WAV
81
- wav_file_path = os.path.join(root_dir, "temp_audio.wav")
82
  if not convert_to_wav(input_file_path, wav_file_path):
83
  logger.error("Audio conversion to WAV failed")
84
  return templates.TemplateResponse("index.html", {
 
23
  # Set up templates
24
  templates = Jinja2Templates(directory="templates")
25
 
 
26
 
27
  # Vosk model path
28
  vosk_model_path = "./vosk-model-small-en-us-0.15"
 
62
  try:
63
  with tempfile.TemporaryDirectory() as temp_dir:
64
  # Save the uploaded file (could be WebM, OGG, etc.)
65
+ input_file_path = os.path.join(temp_dir, "input_audio.webm")
66
  with open(input_file_path, "wb") as buffer:
67
  shutil.copyfileobj(audio_file.file, buffer)
68
  file_size = os.path.getsize(input_file_path) if os.path.exists(input_file_path) else 0
 
77
  })
78
 
79
  # Convert to WAV
80
+ wav_file_path = os.path.join(temp_dir, "temp_audio.wav")
81
  if not convert_to_wav(input_file_path, wav_file_path):
82
  logger.error("Audio conversion to WAV failed")
83
  return templates.TemplateResponse("index.html", {