Spaces:
Running
Running
read file content from blob
Browse files
app.py
CHANGED
@@ -192,7 +192,22 @@ def process_input(input_data):
|
|
192 |
# This is a gradio.FileData object from API calls
|
193 |
try:
|
194 |
print(f"Processing API file: {input_data['path']}")
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
print(f"Converted gloss: {gloss[:100]}...") # Show first 100 chars
|
197 |
return gloss
|
198 |
except Exception as e:
|
|
|
192 |
# This is a gradio.FileData object from API calls
|
193 |
try:
|
194 |
print(f"Processing API file: {input_data['path']}")
|
195 |
+
|
196 |
+
# Read the file content from the blob path
|
197 |
+
with open(input_data['path'], 'rb') as f:
|
198 |
+
file_content = f.read()
|
199 |
+
|
200 |
+
# Check if it's a text file or binary document
|
201 |
+
if input_data.get('mime_type') == 'text/plain' or input_data['path'].endswith('.txt'):
|
202 |
+
# Text file - decode as text
|
203 |
+
text_content = file_content.decode('utf-8')
|
204 |
+
print(f"Extracted {len(text_content)} characters from text file")
|
205 |
+
# Convert text to ASL gloss
|
206 |
+
gloss = asl_converter.asl_converter.convert_text(text_content)
|
207 |
+
else:
|
208 |
+
# Binary document - use document converter
|
209 |
+
gloss = asl_converter.convert_document(input_data['path'])
|
210 |
+
|
211 |
print(f"Converted gloss: {gloss[:100]}...") # Show first 100 chars
|
212 |
return gloss
|
213 |
except Exception as e:
|