Mongar28 commited on
Commit
9fd131c
·
1 Parent(s): ecbe0f5

Se implemento la descarga del archvio de la transcripcion

Browse files
app.py CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
2
  from streamlit_tools.tools import load_audio_file
3
  from openai_models.whisper import whisper_os
4
  import time
 
 
5
 
6
 
7
  def main():
@@ -16,6 +18,16 @@ def main():
16
  yield word + ' '
17
  st.write_stream(transcription_generator(), )
18
  # st.write(transcription)
 
 
 
 
 
 
 
 
 
 
19
 
20
 
21
  if __name__ == "__main__":
 
2
  from streamlit_tools.tools import load_audio_file
3
  from openai_models.whisper import whisper_os
4
  import time
5
+ from documents.docs import generate_docx
6
+ import os
7
 
8
 
9
  def main():
 
18
  yield word + ' '
19
  st.write_stream(transcription_generator(), )
20
  # st.write(transcription)
21
+ #
22
+ generate_docx(transcription["text"])
23
+
24
+ if os.path.exists(st.session_state.full_path_docx):
25
+ with open(st.session_state.full_path_docx, "rb") as file:
26
+ btn = st.download_button(
27
+ label="Download docx",
28
+ data=file,
29
+ file_name=st.session_state.full_path_docx,
30
+ )
31
 
32
 
33
  if __name__ == "__main__":
documents/__init__.py ADDED
File without changes
documents/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (166 Bytes). View file
 
documents/__pycache__/docs.cpython-312.pyc ADDED
Binary file (1.3 kB). View file
 
documents/docs.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import docx
3
+ import streamlit as st
4
+
5
+
6
+ def generate_docx(text: str):
7
+ file_name: str = st.session_state.audio_file_name.replace(".mp3", ".docx")
8
+
9
+ file_path: str = os.path.join("documents", "docs")
10
+
11
+ # Ensure the directory exists
12
+ os.makedirs(file_path, exist_ok=True)
13
+
14
+ # full_path: str = os.path.join(file_path, file_name)
15
+
16
+ if "full_path_docx" not in st.session_state.keys():
17
+ st.session_state.full_path_docx = os.path.join(file_path, file_name)
18
+
19
+ # Crea un nuevo documento
20
+ doc = docx.Document()
21
+
22
+ # Agrega un párrafo al documento
23
+ doc.add_paragraph(f"Texto del audio transcrito:\n\n{text}")
24
+
25
+ # Guarda el documento en un archivo .docx
26
+ doc.save(st.session_state.full_path_docx)
documents/docs/nota_de_voz.ogg ADDED
Binary file (36.7 kB). View file