Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -143,6 +143,27 @@ def copy_lang_dict(data_folder, destination,lang):
|
|
143 |
except Exception as e:
|
144 |
print(f"Error copying {dict_file}: {str(e)}")
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
def compile_espeak():
|
147 |
compile_command = [espeak_path, "--compile=fa"]
|
148 |
cwd_path = os.path.join(static_folder,"dictsource")
|
|
|
143 |
except Exception as e:
|
144 |
print(f"Error copying {dict_file}: {str(e)}")
|
145 |
|
146 |
+
|
147 |
+
import requests
|
148 |
+
def download_files(urls, folder):
|
149 |
+
os.makedirs(folder, exist_ok=True) # Create folder if it doesn't exist
|
150 |
+
for url in urls:
|
151 |
+
filename = os.path.join(folder, url.split('/')[-1]) # Get file name from URL
|
152 |
+
response = requests.get(url)
|
153 |
+
if response.status_code == 200:
|
154 |
+
with open(filename, 'wb') as f:
|
155 |
+
f.write(response.content)
|
156 |
+
print(f'Downloaded: {filename} ✅')
|
157 |
+
else:
|
158 |
+
print(f'Failed to download: {url} ❌')
|
159 |
+
|
160 |
+
urls = [
|
161 |
+
'https://github.com/espeak-ng/espeak-ng/raw/refs/heads/master/dictsource/fa_rules',
|
162 |
+
'https://github.com/espeak-ng/espeak-ng/raw/refs/heads/master/dictsource/fa_list',
|
163 |
+
'https://github.com/espeak-ng/espeak-ng/raw/refs/heads/master/dictsource/fa_extra'
|
164 |
+
]
|
165 |
+
|
166 |
+
download_files(urls, os.path.join(static_folder,"dictsource"))
|
167 |
def compile_espeak():
|
168 |
compile_command = [espeak_path, "--compile=fa"]
|
169 |
cwd_path = os.path.join(static_folder,"dictsource")
|