minhpng commited on
Commit
669dcca
·
1 Parent(s): 6e43888
Files changed (1) hide show
  1. routers/get_transcript.py +45 -3
routers/get_transcript.py CHANGED
@@ -11,8 +11,8 @@ router = APIRouter(prefix="/get-transcript", tags=["transcript"])
11
 
12
  # api_key: str = Depends(get_api_key)
13
  @router.get("/")
14
- def get_transcript(audio_path: str, model_size: str = "distil-large-v3"):
15
- # Run on GPU with FP16
16
  # model = WhisperModel(model_size, device="cuda", compute_type="float16")
17
 
18
  # or run on GPU with INT8
@@ -39,10 +39,52 @@ def get_transcript(audio_path: str, model_size: str = "distil-large-v3"):
39
 
40
  text = ""
41
 
 
 
42
  for segment in segments:
43
  text += segment.text
 
 
 
 
 
 
44
 
45
  et = time.time()
46
  elapsed_time = et - st
47
- return {"text": text}
 
 
 
 
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # api_key: str = Depends(get_api_key)
13
  @router.get("/")
14
+ def get_transcript(audio_path: str, model_size: str = "distil-large-v3", api_key: str = Depends(get_api_key)):
15
+ # Run on GPU with FP16
16
  # model = WhisperModel(model_size, device="cuda", compute_type="float16")
17
 
18
  # or run on GPU with INT8
 
39
 
40
  text = ""
41
 
42
+ listSentences = []
43
+
44
  for segment in segments:
45
  text += segment.text
46
+ listSentences.append({
47
+ "start_time": segment.start,
48
+ "end_time": segment.end,
49
+ "text": segment.text
50
+ })
51
+
52
 
53
  et = time.time()
54
  elapsed_time = et - st
55
+ return {"text": text,
56
+ 'list_sentence': listSentences
57
+ }
58
+
59
+ # time.sleep(5)
60
 
61
+ # return {
62
+ # "text": " She has a dimble on her left cheek, it adds charm to her facial features. The dimple is a genetic trait that she inherited from her mother. She's always been proud of it. People compliment her on it. She can't help but smile wider.",
63
+ # "list_sentence": [
64
+ # {
65
+ # "start_time": 0.0,
66
+ # "end_time": 8.0,
67
+ # "text": " She has a dimble on her left cheek, it adds charm to her facial features."
68
+ # },
69
+ # {
70
+ # "start_time": 8.0,
71
+ # "end_time": 16.0,
72
+ # "text": " The dimple is a genetic trait that she inherited from her mother."
73
+ # },
74
+ # {
75
+ # "start_time": 16.0,
76
+ # "end_time": 20.0,
77
+ # "text": " She's always been proud of it."
78
+ # },
79
+ # {
80
+ # "start_time": 20.0,
81
+ # "end_time": 24.0,
82
+ # "text": " People compliment her on it."
83
+ # },
84
+ # {
85
+ # "start_time": 24.0,
86
+ # "end_time": 28.0,
87
+ # "text": " She can't help but smile wider."
88
+ # }
89
+ # ]
90
+ # }