Spaces:
Runtime error
Runtime error
Added Function to execute shell commands safely
Browse files
app.py
CHANGED
|
@@ -3,13 +3,8 @@ import torch
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
# Loading the TTS and Vocoder ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 6 |
-
!git clone https://github.com/saheedniyi02/yarngpt.git
|
| 7 |
-
!pip install -qU outetts uroman
|
| 8 |
-
|
| 9 |
-
import os
|
| 10 |
import re
|
| 11 |
import json
|
| 12 |
-
import torch
|
| 13 |
import inflect
|
| 14 |
import random
|
| 15 |
import uroman as ur
|
|
@@ -20,6 +15,47 @@ import requests
|
|
| 20 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 21 |
from outetts.wav_tokenizer.decoder import WavTokenizer
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
# Download files using Python's requests library instead of !wget
|
| 24 |
def download_file(url, save_path):
|
| 25 |
response = requests.get(url, stream=True)
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
# Loading the TTS and Vocoder ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
import re
|
| 7 |
import json
|
|
|
|
| 8 |
import inflect
|
| 9 |
import random
|
| 10 |
import uroman as ur
|
|
|
|
| 15 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 16 |
from outetts.wav_tokenizer.decoder import WavTokenizer
|
| 17 |
|
| 18 |
+
# Function to execute shell commands safely
|
| 19 |
+
def run_command(command):
|
| 20 |
+
try:
|
| 21 |
+
process = subprocess.Popen(
|
| 22 |
+
command,
|
| 23 |
+
stdout=subprocess.PIPE,
|
| 24 |
+
stderr=subprocess.PIPE,
|
| 25 |
+
shell=True,
|
| 26 |
+
universal_newlines=True
|
| 27 |
+
)
|
| 28 |
+
stdout, stderr = process.communicate()
|
| 29 |
+
|
| 30 |
+
if process.returncode != 0:
|
| 31 |
+
print(f"Error executing: {command}")
|
| 32 |
+
print(stderr)
|
| 33 |
+
return False
|
| 34 |
+
else:
|
| 35 |
+
print(stdout)
|
| 36 |
+
return True
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f"Exception during execution of {command}: {e}")
|
| 39 |
+
return False
|
| 40 |
+
|
| 41 |
+
# Clone the YarnGPT repository
|
| 42 |
+
if not os.path.exists('yarngpt'):
|
| 43 |
+
print("Cloning YarnGPT repository...")
|
| 44 |
+
run_command("git clone https://github.com/saheedniyi02/yarngpt.git")
|
| 45 |
+
else:
|
| 46 |
+
print("YarnGPT repository already exists")
|
| 47 |
+
|
| 48 |
+
# Install required packages
|
| 49 |
+
print("Installing required packages...")
|
| 50 |
+
run_command("pip install -q outetts uroman")
|
| 51 |
+
|
| 52 |
+
# If you need to install the cloned package in development mode
|
| 53 |
+
if os.path.exists('yarngpt'):
|
| 54 |
+
os.chdir('yarngpt')
|
| 55 |
+
run_command("pip install -e .")
|
| 56 |
+
os.chdir('..') # Go back to the original directory
|
| 57 |
+
|
| 58 |
+
|
| 59 |
# Download files using Python's requests library instead of !wget
|
| 60 |
def download_file(url, save_path):
|
| 61 |
response = requests.get(url, stream=True)
|