Spaces:
Runtime error
Runtime error
ahmadtalha
commited on
Commit
•
a05af10
1
Parent(s):
c44ba13
Update app.py
Browse files
app.py
CHANGED
@@ -76,6 +76,7 @@ def process_audio_to_text(audio_path):
|
|
76 |
"English",
|
77 |
api_name="/s2tt"
|
78 |
)
|
|
|
79 |
return result['text'] # Adjust based on the actual response
|
80 |
|
81 |
def process_text_to_audio(text, target_language="English"):
|
@@ -119,8 +120,6 @@ def process_input(image=None, file=None, audio=None, text=""):
|
|
119 |
for idx in range(len((list(ocr_prediction)[0][1]))):
|
120 |
final_text += " "
|
121 |
final_text += list((list(ocr_prediction)[0][1])[idx])[1][1]
|
122 |
-
# final_text += "\n" + ocr_processor.process_image(image)
|
123 |
-
print(final_text)
|
124 |
if file is not None:
|
125 |
if file.name.lower().endswith(('.png', '.jpg', '.jpeg')):
|
126 |
pil_image = Image.open(file)
|
@@ -129,17 +128,15 @@ def process_input(image=None, file=None, audio=None, text=""):
|
|
129 |
for idx in range(len((list(ocr_prediction)[0][1]))):
|
130 |
final_text += " "
|
131 |
final_text += list((list(ocr_prediction)[0][1])[idx])[1][1]
|
132 |
-
print(final_text)
|
133 |
elif file.name.lower().endswith('.pdf'):
|
134 |
ocr_prediction = ocr_processor.process_pdf(file.name)
|
135 |
# gettig text from ocr object
|
136 |
for idx in range(len((list(ocr_prediction)[0][1]))):
|
137 |
final_text += " "
|
138 |
final_text += list((list(ocr_prediction)[0][1])[idx])[1][1]
|
139 |
-
print(final_text)
|
140 |
-
# final_text += "\n" + ocr_processor.process_pdf(file.name)
|
141 |
else:
|
142 |
final_text += "\nUnsupported file type."
|
|
|
143 |
if audio is not None:
|
144 |
audio_text = process_audio_to_text(audio)
|
145 |
final_text += "\n" + audio_text
|
@@ -151,6 +148,7 @@ def process_input(image=None, file=None, audio=None, text=""):
|
|
151 |
temperature=0.5
|
152 |
)
|
153 |
generated_text = response.generations[0].text
|
|
|
154 |
|
155 |
# Process generated text with command-nightly model
|
156 |
response = co.generate(
|
|
|
76 |
"English",
|
77 |
api_name="/s2tt"
|
78 |
)
|
79 |
+
print("Audio Result: ", result)
|
80 |
return result['text'] # Adjust based on the actual response
|
81 |
|
82 |
def process_text_to_audio(text, target_language="English"):
|
|
|
120 |
for idx in range(len((list(ocr_prediction)[0][1]))):
|
121 |
final_text += " "
|
122 |
final_text += list((list(ocr_prediction)[0][1])[idx])[1][1]
|
|
|
|
|
123 |
if file is not None:
|
124 |
if file.name.lower().endswith(('.png', '.jpg', '.jpeg')):
|
125 |
pil_image = Image.open(file)
|
|
|
128 |
for idx in range(len((list(ocr_prediction)[0][1]))):
|
129 |
final_text += " "
|
130 |
final_text += list((list(ocr_prediction)[0][1])[idx])[1][1]
|
|
|
131 |
elif file.name.lower().endswith('.pdf'):
|
132 |
ocr_prediction = ocr_processor.process_pdf(file.name)
|
133 |
# gettig text from ocr object
|
134 |
for idx in range(len((list(ocr_prediction)[0][1]))):
|
135 |
final_text += " "
|
136 |
final_text += list((list(ocr_prediction)[0][1])[idx])[1][1]
|
|
|
|
|
137 |
else:
|
138 |
final_text += "\nUnsupported file type."
|
139 |
+
print(final_text)
|
140 |
if audio is not None:
|
141 |
audio_text = process_audio_to_text(audio)
|
142 |
final_text += "\n" + audio_text
|
|
|
148 |
temperature=0.5
|
149 |
)
|
150 |
generated_text = response.generations[0].text
|
151 |
+
print("Generated Text: ", generated_text)
|
152 |
|
153 |
# Process generated text with command-nightly model
|
154 |
response = co.generate(
|