OpenSound commited on
Commit
8abe49d
·
verified ·
1 Parent(s): 5d2baa5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -29
app.py CHANGED
@@ -32,35 +32,44 @@ MODELS_PATH = os.getenv("MODELS_PATH", "./pretrained_models")
32
  os.makedirs(MODELS_PATH, exist_ok=True)
33
  device = "cuda" if torch.cuda.is_available() else "cpu"
34
 
35
- # download wmencodec
36
- url = "https://huggingface.co/westbrook/SSR-Speech-English/resolve/main/wmencodec.th"
37
- filename = os.path.join(MODELS_PATH, "wmencodec.th")
38
- response = requests.get(url, stream=True)
39
- response.raise_for_status()
40
- with open(filename, "wb") as file:
41
- for chunk in response.iter_content(chunk_size=8192):
42
- file.write(chunk)
43
- print(f"File downloaded to: {filename}")
44
-
45
- # download english model
46
- url = "https://huggingface.co/westbrook/SSR-Speech-English/resolve/main/English.pth"
47
- filename = os.path.join(MODELS_PATH, "English.th")
48
- response = requests.get(url, stream=True)
49
- response.raise_for_status()
50
- with open(filename, "wb") as file:
51
- for chunk in response.iter_content(chunk_size=8192):
52
- file.write(chunk)
53
- print(f"File downloaded to: {filename}")
54
-
55
- # download mandarin model
56
- url = "https://huggingface.co/westbrook/SSR-Speech-Mandarin/resolve/main/Mandarin.pth"
57
- filename = os.path.join(MODELS_PATH, "Mandarin.pth")
58
- response = requests.get(url, stream=True)
59
- response.raise_for_status()
60
- with open(filename, "wb") as file:
61
- for chunk in response.iter_content(chunk_size=8192):
62
- file.write(chunk)
63
- print(f"File downloaded to: {filename}")
 
 
 
 
 
 
 
 
 
64
 
65
  def get_random_string():
66
  return "".join(str(uuid.uuid4()).split("-"))
 
32
  os.makedirs(MODELS_PATH, exist_ok=True)
33
  device = "cuda" if torch.cuda.is_available() else "cpu"
34
 
35
+ if not os.path.exists(os.path.join(MODELS_PATH, "wmencodec.th")):
36
+ # download wmencodec
37
+ url = "https://huggingface.co/westbrook/SSR-Speech-English/resolve/main/wmencodec.th"
38
+ filename = os.path.join(MODELS_PATH, "wmencodec.th")
39
+ response = requests.get(url, stream=True)
40
+ response.raise_for_status()
41
+ with open(filename, "wb") as file:
42
+ for chunk in response.iter_content(chunk_size=8192):
43
+ file.write(chunk)
44
+ print(f"File downloaded to: {filename}")
45
+ else:
46
+ print("wmencodec model found")
47
+
48
+ if not os.path.exists(os.path.join(MODELS_PATH, "English.pth")):
49
+ # download english model
50
+ url = "https://huggingface.co/westbrook/SSR-Speech-English/resolve/main/English.pth"
51
+ filename = os.path.join(MODELS_PATH, "English.pth")
52
+ response = requests.get(url, stream=True)
53
+ response.raise_for_status()
54
+ with open(filename, "wb") as file:
55
+ for chunk in response.iter_content(chunk_size=8192):
56
+ file.write(chunk)
57
+ print(f"File downloaded to: {filename}")
58
+ else:
59
+ print("english model found")
60
+
61
+ if not os.path.exists(os.path.join(MODELS_PATH, "Mandarin.pth")):
62
+ # download mandarin model
63
+ url = "https://huggingface.co/westbrook/SSR-Speech-Mandarin/resolve/main/Mandarin.pth"
64
+ filename = os.path.join(MODELS_PATH, "Mandarin.pth")
65
+ response = requests.get(url, stream=True)
66
+ response.raise_for_status()
67
+ with open(filename, "wb") as file:
68
+ for chunk in response.iter_content(chunk_size=8192):
69
+ file.write(chunk)
70
+ print(f"File downloaded to: {filename}")
71
+ else:
72
+ print("mandarin model found")
73
 
74
  def get_random_string():
75
  return "".join(str(uuid.uuid4()).split("-"))