Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,16 +27,16 @@ user_prompt_template = (
|
|
27 |
"author, but enhance readability and flow. Do not add embellishments or AI-style phrasing."
|
28 |
)
|
29 |
|
30 |
-
# === Encode uploaded
|
31 |
def encode_image_to_base64(file_bytes):
|
32 |
-
return base64.b64encode(file_bytes
|
33 |
|
34 |
# === Transcription logic ===
|
35 |
-
def transcribe_image(
|
36 |
-
if not
|
37 |
return "No image uploaded."
|
38 |
|
39 |
-
encoded = encode_image_to_base64(
|
40 |
image_url = f"data:image/jpeg;base64,{encoded}"
|
41 |
|
42 |
response = client.chat.completions.create(
|
@@ -63,4 +63,5 @@ with gr.Blocks() as app:
|
|
63 |
|
64 |
# === Launch ===
|
65 |
if __name__ == "__main__":
|
66 |
-
app.launch(
|
|
|
|
27 |
"author, but enhance readability and flow. Do not add embellishments or AI-style phrasing."
|
28 |
)
|
29 |
|
30 |
+
# === Encode uploaded bytes ===
|
31 |
def encode_image_to_base64(file_bytes):
|
32 |
+
return base64.b64encode(file_bytes).decode("utf-8")
|
33 |
|
34 |
# === Transcription logic ===
|
35 |
+
def transcribe_image(file_bytes):
|
36 |
+
if not file_bytes:
|
37 |
return "No image uploaded."
|
38 |
|
39 |
+
encoded = encode_image_to_base64(file_bytes)
|
40 |
image_url = f"data:image/jpeg;base64,{encoded}"
|
41 |
|
42 |
response = client.chat.completions.create(
|
|
|
63 |
|
64 |
# === Launch ===
|
65 |
if __name__ == "__main__":
|
66 |
+
app.launch()
|
67 |
+
|