Change default temp
Browse files
app.py
CHANGED
|
@@ -114,15 +114,15 @@ with gr.Blocks(title="😻 KaniTTS - Text to Speech", theme=gr.themes.Default())
|
|
| 114 |
|
| 115 |
with gr.Accordion("Settings", open=False):
|
| 116 |
temp = gr.Slider(
|
| 117 |
-
minimum=0.1, maximum=1.5, value=
|
| 118 |
label="Temp",
|
| 119 |
)
|
| 120 |
top_p = gr.Slider(
|
| 121 |
-
minimum=0.1, maximum=1.0, value=
|
| 122 |
label="Top P",
|
| 123 |
)
|
| 124 |
rp = gr.Slider(
|
| 125 |
-
minimum=1.0, maximum=2.0, value=1.
|
| 126 |
label="Repetition Penalty",
|
| 127 |
)
|
| 128 |
max_tok = gr.Slider(
|
|
@@ -156,14 +156,14 @@ with gr.Blocks(title="😻 KaniTTS - Text to Speech", theme=gr.themes.Default())
|
|
| 156 |
with gr.Row():
|
| 157 |
|
| 158 |
examples = [
|
| 159 |
-
["Anyway, um, so, um, tell me, tell me all about her. I mean, what's she like? Is she really, you know, pretty?", "male",
|
| 160 |
-
["No, that does not make you a failure. No, sweetie, no. It just, uh, it just means that you're having a tough time...", "male",
|
| 161 |
-
["I-- Oh, I am such an idiot sometimes. I'm so sorry. Um, I-I don't know where my head's at.", "male",
|
| 162 |
-
["Got it. $300,000. I can definitely help you get a very good price for your property by selecting a realtor.", "female",
|
| 163 |
-
["Holy fu- Oh my God! Don't you understand how dangerous it is, huh?", "male",
|
| 164 |
-
["You make my days brighter, and my wildest dreams feel like reality. How do you do that?", "female",
|
| 165 |
-
["Great, and just a couple quick questions so we can match you with the right buyer. Is your home address still 330 East Charleston Road?", "female",
|
| 166 |
-
["Oh, yeah. I mean did you want to get a quick snack together or maybe something before you go?", "female",
|
| 167 |
]
|
| 168 |
|
| 169 |
|
|
|
|
| 114 |
|
| 115 |
with gr.Accordion("Settings", open=False):
|
| 116 |
temp = gr.Slider(
|
| 117 |
+
minimum=0.1, maximum=1.5, value=1.4, step=0.05,
|
| 118 |
label="Temp",
|
| 119 |
)
|
| 120 |
top_p = gr.Slider(
|
| 121 |
+
minimum=0.1, maximum=1.0, value=1.4, step=0.05,
|
| 122 |
label="Top P",
|
| 123 |
)
|
| 124 |
rp = gr.Slider(
|
| 125 |
+
minimum=1.0, maximum=2.0, value=1.4, step=0.05,
|
| 126 |
label="Repetition Penalty",
|
| 127 |
)
|
| 128 |
max_tok = gr.Slider(
|
|
|
|
| 156 |
with gr.Row():
|
| 157 |
|
| 158 |
examples = [
|
| 159 |
+
["Anyway, um, so, um, tell me, tell me all about her. I mean, what's she like? Is she really, you know, pretty?", "male", 1.4, 0.95, 1.1, 1200],
|
| 160 |
+
["No, that does not make you a failure. No, sweetie, no. It just, uh, it just means that you're having a tough time...", "male", 1.4, 0.95, 1.1, 1200],
|
| 161 |
+
["I-- Oh, I am such an idiot sometimes. I'm so sorry. Um, I-I don't know where my head's at.", "male", 1.4, 0.95, 1.1, 1200],
|
| 162 |
+
["Got it. $300,000. I can definitely help you get a very good price for your property by selecting a realtor.", "female", 1.4, 0.95, 1.1, 1200],
|
| 163 |
+
["Holy fu- Oh my God! Don't you understand how dangerous it is, huh?", "male", 1.4, 0.95, 1.1, 1200],
|
| 164 |
+
["You make my days brighter, and my wildest dreams feel like reality. How do you do that?", "female", 1.4, 0.95, 1.1, 1200],
|
| 165 |
+
["Great, and just a couple quick questions so we can match you with the right buyer. Is your home address still 330 East Charleston Road?", "female", 1.4, 0.95, 1.1, 1200],
|
| 166 |
+
["Oh, yeah. I mean did you want to get a quick snack together or maybe something before you go?", "female", 1.4, 0.95, 1.1, 1200],
|
| 167 |
]
|
| 168 |
|
| 169 |
|
util.py
CHANGED
|
@@ -17,7 +17,7 @@ class Config:
|
|
| 17 |
start_of_text: int = 1
|
| 18 |
end_of_text: int = 2
|
| 19 |
max_new_tokens: int = 1200
|
| 20 |
-
temperature: float = .
|
| 21 |
top_p: float = .95
|
| 22 |
repetition_penalty: float = 1.1
|
| 23 |
|
|
@@ -141,7 +141,7 @@ class KaniModel:
|
|
| 141 |
# Load model with proper configuration
|
| 142 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 143 |
self.conf.model_name,
|
| 144 |
-
|
| 145 |
device_map=self.conf.device_map,
|
| 146 |
token=token,
|
| 147 |
trust_remote_code=True # May be needed for some models
|
|
@@ -223,49 +223,3 @@ class KaniModel:
|
|
| 223 |
point_3 = time.time()
|
| 224 |
return audio, text, self.time_report(point_1, point_2, point_3)
|
| 225 |
|
| 226 |
-
|
| 227 |
-
class Demo:
|
| 228 |
-
def __init__(self):
|
| 229 |
-
self.audio_dir = './audio_examples'
|
| 230 |
-
os.makedirs(self.audio_dir, exist_ok=True)
|
| 231 |
-
self.sentences = [
|
| 232 |
-
"You make my days brighter, and my wildest dreams feel like reality. How do you do that?",
|
| 233 |
-
"Anyway, um, so, um, tell me, tell me all about her. I mean, what's she like? Is she really, you know, pretty?",
|
| 234 |
-
"Great, and just a couple quick questions so we can match you with the right buyer. Is your home address still 330 East Charleston Road?",
|
| 235 |
-
"No, that does not make you a failure. No, sweetie, no. It just, uh, it just means that you're having a tough time...",
|
| 236 |
-
"Oh, yeah. I mean did you want to get a quick snack together or maybe something before you go?",
|
| 237 |
-
"I-- Oh, I am such an idiot sometimes. I'm so sorry. Um, I-I don't know where my head's at.",
|
| 238 |
-
"Got it. $300,000. I can definitely help you get a very good price for your property by selecting a realtor.",
|
| 239 |
-
"Holy fu- Oh my God! Don't you understand how dangerous it is, huh?"
|
| 240 |
-
]
|
| 241 |
-
self.urls = [
|
| 242 |
-
'https://www.nineninesix.ai/examples/kani/1.wav',
|
| 243 |
-
'https://www.nineninesix.ai/examples/kani/2.wav',
|
| 244 |
-
'https://www.nineninesix.ai/examples/kani/5.wav',
|
| 245 |
-
'https://www.nineninesix.ai/examples/kani/6.wav',
|
| 246 |
-
'https://www.nineninesix.ai/examples/kani/3.wav',
|
| 247 |
-
'https://www.nineninesix.ai/examples/kani/7.wav',
|
| 248 |
-
'https://www.nineninesix.ai/examples/kani/4.wav',
|
| 249 |
-
'https://www.nineninesix.ai/examples/kani/8.wav'
|
| 250 |
-
]
|
| 251 |
-
|
| 252 |
-
def download_audio(self, url: str, filename: str):
|
| 253 |
-
filepath = os.path.join(self.audio_dir, filename)
|
| 254 |
-
if not os.path.exists(filepath):
|
| 255 |
-
r = requests.get(url)
|
| 256 |
-
r.raise_for_status()
|
| 257 |
-
with open(filepath, 'wb') as f:
|
| 258 |
-
f.write(r.content)
|
| 259 |
-
return filepath
|
| 260 |
-
|
| 261 |
-
def get_audio(self, filepath: str):
|
| 262 |
-
arr, _ = librosa.load(filepath, sr=22050)
|
| 263 |
-
return arr
|
| 264 |
-
|
| 265 |
-
def __call__(self):
|
| 266 |
-
examples = []
|
| 267 |
-
for idx, (sentence, url) in enumerate(zip(self.sentences, self.urls), start=1):
|
| 268 |
-
filename = f"{idx}.wav"
|
| 269 |
-
filepath = self.download_audio(url, filename)
|
| 270 |
-
examples.append([sentence, self.get_audio(filepath)])
|
| 271 |
-
return examples
|
|
|
|
| 17 |
start_of_text: int = 1
|
| 18 |
end_of_text: int = 2
|
| 19 |
max_new_tokens: int = 1200
|
| 20 |
+
temperature: float = 1.4
|
| 21 |
top_p: float = .95
|
| 22 |
repetition_penalty: float = 1.1
|
| 23 |
|
|
|
|
| 141 |
# Load model with proper configuration
|
| 142 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 143 |
self.conf.model_name,
|
| 144 |
+
dtype=torch.bfloat16,
|
| 145 |
device_map=self.conf.device_map,
|
| 146 |
token=token,
|
| 147 |
trust_remote_code=True # May be needed for some models
|
|
|
|
| 223 |
point_3 = time.time()
|
| 224 |
return audio, text, self.time_report(point_1, point_2, point_3)
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|