kevinwang676 commited on
Commit
4fb477f
·
verified ·
1 Parent(s): 330ae58

Update models/model.py

Browse files
Files changed (1) hide show
  1. models/model.py +13 -0
models/model.py CHANGED
@@ -5,6 +5,8 @@ import requests
5
  import json
6
  import torch
7
  import os
 
 
8
  from inference import Inference
9
  import gradio as gr
10
  from constants import VOICE_METHODS, BARK_VOICES, EDGE_VOICES, zips_folder, unzips_folder
@@ -66,7 +68,18 @@ def compress(modelname, files):
66
  return file_path
67
 
68
  # download the model only
 
 
 
 
 
69
 
 
 
 
 
 
 
70
  def download_online_model(url):
71
  url = url.strip()
72
  if url.startswith('https://download.openxlab.org.cn/models/'):
 
5
  import json
6
  import torch
7
  import os
8
+ import re
9
+ import urllib.request
10
  from inference import Inference
11
  import gradio as gr
12
  from constants import VOICE_METHODS, BARK_VOICES, EDGE_VOICES, zips_folder, unzips_folder
 
68
  return file_path
69
 
70
  # download the model only
71
+ def get_username(url):
72
+ match_username = re.search(r'models/(.*?)/', url)
73
+ if match_username:
74
+ result = match_username.group(1)
75
+ return result
76
 
77
+ def get_username_hf(url):
78
+ match_username = re.search(r'huggingface.co/(.*?)/', url)
79
+ if match_username:
80
+ result = match_username.group(1)
81
+ return result
82
+
83
  def download_online_model(url):
84
  url = url.strip()
85
  if url.startswith('https://download.openxlab.org.cn/models/'):