Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -20,7 +20,9 @@ translate_token_id = all_special_ids[-6]
|
|
20 |
def transcribe(file):
|
21 |
pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id]]
|
22 |
text = pipe(file, return_timestamps=True)
|
23 |
-
|
|
|
|
|
24 |
return text
|
25 |
|
26 |
app = FastAPI()
|
@@ -30,9 +32,10 @@ def transcribe(background_tasks: BackgroundTasks, file: UploadFile = File(...)):
|
|
30 |
background_tasks.add_task(transcribe, file)
|
31 |
return {"text": "Processing file..."}
|
32 |
|
33 |
-
@app.get("/")
|
34 |
-
def
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
20 |
def transcribe(file):
|
21 |
pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id]]
|
22 |
text = pipe(file, return_timestamps=True)
|
23 |
+
file_path = '/home/user/data/new_file.txt'
|
24 |
+
with open(file_path, "w") as file:
|
25 |
+
file.write(text)
|
26 |
return text
|
27 |
|
28 |
app = FastAPI()
|
|
|
32 |
background_tasks.add_task(transcribe, file)
|
33 |
return {"text": "Processing file..."}
|
34 |
|
35 |
+
@app.get("/get-text")
|
36 |
+
def get_text():
|
37 |
+
file = open('/home/user/data/new_file.txt', 'r')
|
38 |
+
content = file.read()
|
39 |
+
file.close()
|
40 |
+
|
41 |
+
return {"text": content}
|