yanielbf commited on
Commit
2fc4e17
·
1 Parent(s): e92a84a

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -7
main.py CHANGED
@@ -26,6 +26,8 @@ all_special_ids = pipe.tokenizer.all_special_ids
26
  transcribe_token_id = all_special_ids[-5]
27
  translate_token_id = all_special_ids[-6]
28
 
 
 
29
  def transcribe():
30
  try:
31
  print("For processing...")
@@ -37,18 +39,12 @@ def transcribe():
37
  pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id]]
38
  print("Call pipeline...")
39
  text = pipe('/home/user/data/audio.mp3', return_timestamps=True)
40
- print("Save file...")
41
- file_path = '/home/user/data/new_file.txt'
42
- with open(file_path, "w") as file:
43
- file.write(text)
44
  print(text)
45
  except error:
46
  print(error)
47
 
48
- app = FastAPI()
49
-
50
  @app.post("/transcribe")
51
- def transcribe(background_tasks: BackgroundTasks):
52
  background_tasks.add_task(transcribe)
53
  return {"text": "Processing file..."}
54
 
 
26
  transcribe_token_id = all_special_ids[-5]
27
  translate_token_id = all_special_ids[-6]
28
 
29
+ app = FastAPI()
30
+
31
  def transcribe():
32
  try:
33
  print("For processing...")
 
39
  pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id]]
40
  print("Call pipeline...")
41
  text = pipe('/home/user/data/audio.mp3', return_timestamps=True)
 
 
 
 
42
  print(text)
43
  except error:
44
  print(error)
45
 
 
 
46
  @app.post("/transcribe")
47
+ async def transcribe(background_tasks: BackgroundTasks):
48
  background_tasks.add_task(transcribe)
49
  return {"text": "Processing file..."}
50