Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
|
@@ -51,8 +52,9 @@ def default_table():
|
|
51 |
"Title": ["", "", "", "", ""]
|
52 |
})
|
53 |
|
54 |
-
def substitute_names(speaker_names, text):
|
55 |
|
|
|
|
|
56 |
df = speaker_names.itertuples(index=False)
|
57 |
for default, name, title in df:
|
58 |
if title != "":
|
@@ -60,13 +62,15 @@ def substitute_names(speaker_names, text):
|
|
60 |
|
61 |
text = text.replace(default, f"{name}{title}")
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
66 |
|
67 |
-
|
68 |
-
|
69 |
|
|
|
70 |
|
71 |
def main(conf):
|
72 |
|
|
|
1 |
import os
|
2 |
+
import tempfile
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
|
|
|
52 |
"Title": ["", "", "", "", ""]
|
53 |
})
|
54 |
|
|
|
55 |
|
56 |
+
|
57 |
+
def substitute_names(speaker_names, text):
|
58 |
df = speaker_names.itertuples(index=False)
|
59 |
for default, name, title in df:
|
60 |
if title != "":
|
|
|
62 |
|
63 |
text = text.replace(default, f"{name}{title}")
|
64 |
|
65 |
+
# Generate a unique temporary file name
|
66 |
+
temp_file = tempfile.NamedTemporaryFile(suffix='.txt', delete=False)
|
67 |
+
temp_file_name = temp_file.name
|
68 |
+
temp_file.close() # Close the file to allow other processes to access it
|
69 |
|
70 |
+
with open(temp_file_name, "w") as file:
|
71 |
+
file.write(text)
|
72 |
|
73 |
+
return temp_file_name
|
74 |
|
75 |
def main(conf):
|
76 |
|