csukuangfj commited on
Commit
463d335
1 Parent(s): a4f1715

small fixes

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -23,13 +23,13 @@ import logging
23
  import os
24
  import tempfile
25
  import time
 
 
26
  from datetime import datetime
27
 
28
  import gradio as gr
29
  import torch
30
  import torchaudio
31
- import urllib.request
32
-
33
 
34
  from examples import examples
35
  from model import decode, get_pretrained_model, language_to_models, sample_rate
@@ -39,12 +39,11 @@ languages = list(language_to_models.keys())
39
 
40
  def convert_to_wav(in_filename: str) -> str:
41
  """Convert the input audio file to a wave file"""
42
- out_filename = in_filename + ".wav"
 
 
43
  logging.info(f"Converting '{in_filename}' to '{out_filename}'")
44
  _ = os.system(f"ffmpeg -hide_banner -i '{in_filename}' -ar 16000 '{out_filename}'")
45
- _ = os.system(
46
- f"ffmpeg -hide_banner -loglevel error -i '{in_filename}' -ar 16000 '{out_filename}.flac'"
47
- )
48
 
49
  return out_filename
50
 
 
23
  import os
24
  import tempfile
25
  import time
26
+ import urllib.request
27
+ import uuid
28
  from datetime import datetime
29
 
30
  import gradio as gr
31
  import torch
32
  import torchaudio
 
 
33
 
34
  from examples import examples
35
  from model import decode, get_pretrained_model, language_to_models, sample_rate
 
39
 
40
  def convert_to_wav(in_filename: str) -> str:
41
  """Convert the input audio file to a wave file"""
42
+ out_filename = str(uuid.uuid4())
43
+ out_filename = f"{in_filename}.wav"
44
+
45
  logging.info(f"Converting '{in_filename}' to '{out_filename}'")
46
  _ = os.system(f"ffmpeg -hide_banner -i '{in_filename}' -ar 16000 '{out_filename}'")
 
 
 
47
 
48
  return out_filename
49