Spaces:
Runtime error
Runtime error
added save_image function
Browse files
app.py
CHANGED
|
@@ -97,6 +97,28 @@ def save_audio(audio_input, output_dir="saved_audio"):
|
|
| 97 |
|
| 98 |
return file_path
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
def process_speech(input_language, audio_input):
|
| 101 |
"""
|
| 102 |
processing sound using seamless_m4t
|
|
|
|
| 97 |
|
| 98 |
return file_path
|
| 99 |
|
| 100 |
+
def save_image(image_input, output_dir="saved_images"):
|
| 101 |
+
if not os.path.exists(output_dir):
|
| 102 |
+
os.makedirs(output_dir)
|
| 103 |
+
|
| 104 |
+
# Assuming image_input is a NumPy array
|
| 105 |
+
if isinstance(image_input, np.ndarray):
|
| 106 |
+
# Convert NumPy array to PIL Image
|
| 107 |
+
image = Image.fromarray(image_input)
|
| 108 |
+
|
| 109 |
+
# Generate a unique file name
|
| 110 |
+
file_name = f"image_{int(time.time())}.png"
|
| 111 |
+
file_path = os.path.join(output_dir, file_name)
|
| 112 |
+
|
| 113 |
+
# Save the image file
|
| 114 |
+
image.save(file_path)
|
| 115 |
+
|
| 116 |
+
return file_path
|
| 117 |
+
else:
|
| 118 |
+
raise ValueError("Invalid image input type")
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
|
| 122 |
def process_speech(input_language, audio_input):
|
| 123 |
"""
|
| 124 |
processing sound using seamless_m4t
|