ron numerals
Browse files- api.py +2 -2
- assets/ocr.txt +5 -3
- demo.py +1 -1
- msinference.py +65 -23
api.py
CHANGED
@@ -62,8 +62,8 @@ def overlay(x,soundscape=None):
|
|
62 |
).detach().cpu().numpy() # bs, 11400 @.74s
|
63 |
|
64 |
# blend TTS
|
65 |
-
|
66 |
-
x = .
|
67 |
# TTS & AudioGen at 24kHz
|
68 |
return x
|
69 |
|
|
|
62 |
).detach().cpu().numpy() # bs, 11400 @.74s
|
63 |
|
64 |
# blend TTS
|
65 |
+
# background /= np.abs(background).max() + 1e-7 # amplify speech to full [-1,1]
|
66 |
+
x = .4 * x + .46 * background[:len(x)]
|
67 |
# TTS & AudioGen at 24kHz
|
68 |
return x
|
69 |
|
assets/ocr.txt
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
-
MIHAI VODA VITEASUL
|
2 |
|
3 |
-
1593
|
4 |
|
5 |
MIHAIL DOMNUL TAREI ROMANESIT STRALUCITOR IN NOROCIRE SI IN NENOROCIRE SI VIRTUOS IN AMANDOUA IN VARSTA DE 43 ANI!
|
6 |
|
7 |
-
PRECUVÂNTARE
|
|
|
8 |
LA I-ia EDIȚIUNE, TIPĂRITĂ LA 1877.
|
|
|
9 |
Indeplinesc astăzi una din cele mai vii şi mai stăruitoare ale mele dorinţe: aceia de a scoate la lumină Istoria Românilor sub Mihaiu Vodă Viteazul, lucrarea de căpetenie a eminentului şi mult-deplânsului nostru istoric Nicolae Bălcescu, care tot de odată este și o scriere de frunte în literele româneşti.
|
10 |
De două-zeci şi cinci de ani, de când Nicolae Bălcescu a murit, înstrăinat de prea iubita şi prea dorita sa țară, eu unul n'am pregetat un moment de a căuta mijloc spre a face cunoscută publicului românesc această frumoasă operă, în care îşi pironise mintea şi puterile sale un om de un rar talent, pe care, de copil încă, mă deprinsesem a-l respecta, a-l iubi, a-l admira.
|
11 |
Cinci-spre-zece ani din aceştia, am păstrat cu sfințenie la mine manuscriptele lui, cercându-mă de câte ori mi-a stat în putere, a da publicităţei cel puţin o parte din ele. Dar, spre ruşinarea noastră de până acum, a trecut un pătrar de se- col de la moartea Bălcescului mai nainte ca să poată fi pus sub ochii națiunei române, tot ceiace dansul lucrase intru cea mai mare aei onoare!
|
|
|
1 |
+
MIHAI VODA VITEASUL.
|
2 |
|
3 |
+
Care a trăit între 1593 și 1601.
|
4 |
|
5 |
MIHAIL DOMNUL TAREI ROMANESIT STRALUCITOR IN NOROCIRE SI IN NENOROCIRE SI VIRTUOS IN AMANDOUA IN VARSTA DE 43 ANI!
|
6 |
|
7 |
+
PRECUVÂNTARE.
|
8 |
+
|
9 |
LA I-ia EDIȚIUNE, TIPĂRITĂ LA 1877.
|
10 |
+
|
11 |
Indeplinesc astăzi una din cele mai vii şi mai stăruitoare ale mele dorinţe: aceia de a scoate la lumină Istoria Românilor sub Mihaiu Vodă Viteazul, lucrarea de căpetenie a eminentului şi mult-deplânsului nostru istoric Nicolae Bălcescu, care tot de odată este și o scriere de frunte în literele româneşti.
|
12 |
De două-zeci şi cinci de ani, de când Nicolae Bălcescu a murit, înstrăinat de prea iubita şi prea dorita sa țară, eu unul n'am pregetat un moment de a căuta mijloc spre a face cunoscută publicului românesc această frumoasă operă, în care îşi pironise mintea şi puterile sale un om de un rar talent, pe care, de copil încă, mă deprinsesem a-l respecta, a-l iubi, a-l admira.
|
13 |
Cinci-spre-zece ani din aceştia, am păstrat cu sfințenie la mine manuscriptele lui, cercându-mă de câte ori mi-a stat în putere, a da publicităţei cel puţin o parte din ele. Dar, spre ruşinarea noastră de până acum, a trecut un pătrar de se- col de la moartea Bălcescului mai nainte ca să poată fi pus sub ochii națiunei române, tot ceiace dansul lucrase intru cea mai mare aei onoare!
|
demo.py
CHANGED
@@ -16,7 +16,7 @@ def tts_entry(text='»Vom Prof. Friedrich ist noch eine recht schöne große Lan
|
|
16 |
'A quick brown fox jumps over the lazy dog. Sweet dreams are made of this, I traveled the world and the seven seas.'
|
17 |
'DESCIPTION Bronzezeitlicher Zeremonialhut („Berliner Goldhut“), gefertigt aus einem Stück nahtlos getriebenem Goldblech und mit Kreisornamenten in Repousse-Technik verziert. Kalotte kegelförmig überhöht und mit breiter umlaufender Krempe. Krempe und Kalotte durch flaches Bronzeband verstärkt. An der Krempe außen tordierter Bronzedraht. Die Anordnung der Ornamentik auf Kalotte und Krempe des Zeremonialhutes wird als Darstellung eines Kalendersystems gedeutet, mit dem sich die Verschiebungen zwischen Sonnen- und Mondjahr berechnen und Mondfinsternisse voraussagen lassen.'
|
18 |
'Vorderseite: L IVL AVR SVLP ANTONINVS [LP ligiert]. Panzerbüste des Uranius Antoninus mit Lorbeerkranz in der Brustansicht nach l., Pteryges des r. Armansatzes sind zur Angabe eines erhobenen Armes waagerecht dargestellt. Rückseite: CONSERVATO-R AVG. Der Stein des Baal von Emesa auf einem Viergespann (quadriga) nach l. Auf dem Stein, der von zwei Schirmen gerahmt ist, ist das Relief eines Adlers zu sehen. Kommentar: Baldus (1971) 84 ff. 87 zur Frage der Münzstätte, ebd. 128 ff. zur Pterygesanhebung (Andeutung eines erhobenen Armes), die als alexanderhafter Gestus gilt. - Uranius Antoninus wurde im Sommer 253 n. Chr. im syrischen Emesa zum Kaiser erhoben und bewährte sich bald darauf bei der erfolgreichen Abwehr eines Einfalls der Sasaniden. Uranius Antoninus stammte möglicherweise aus der Familie der Iulia Domna, war Priester des Baals von Emesa, und ist mit dem literarisch überlieferten Sampsigeramus identisch, der als Organisator des Widerstandes gegen die Sasaniden in der Region belegt ist. Nach 254 n. Chr. fehlen Informationen über Uranius Antoninus, möglicherweise trat er nach Bereinigung der Notsituation hinter den Kaiser Valerianus zurück. Zu diesem Stück wurden 2017 im Zuge der Ausstellung Syria Antiqua zwei vergrößerte Reproduktionen (3D-Ausdrucke) erstellt, die bei den Galvanos in Schrank 81/121 liegen. Literatur: A. von Sallet, ZfN 17, 1890, 241 f. Taf. 4,9 (dieses Stück); H. R. Baldus, Uranius Antoninus (1971) 198 Nr. 85 Taf. 7,85; 12,85 (dieses Stück, mit Lit., 253/254 n. Chr. bzw. Stempelgruppe VIII ca. Dez. 253-Anfang 254 n. Chr.); RIC IV-3 Nr. 2 c; RPC IX Nr. 1940,2 Taf. 131 (dieses Stück).',
|
19 |
-
voice='
|
20 |
speed=1.14,
|
21 |
affect = True, # False = higher clarity
|
22 |
soundscape = 'dogs barg in dungeons n dragons'
|
|
|
16 |
'A quick brown fox jumps over the lazy dog. Sweet dreams are made of this, I traveled the world and the seven seas.'
|
17 |
'DESCIPTION Bronzezeitlicher Zeremonialhut („Berliner Goldhut“), gefertigt aus einem Stück nahtlos getriebenem Goldblech und mit Kreisornamenten in Repousse-Technik verziert. Kalotte kegelförmig überhöht und mit breiter umlaufender Krempe. Krempe und Kalotte durch flaches Bronzeband verstärkt. An der Krempe außen tordierter Bronzedraht. Die Anordnung der Ornamentik auf Kalotte und Krempe des Zeremonialhutes wird als Darstellung eines Kalendersystems gedeutet, mit dem sich die Verschiebungen zwischen Sonnen- und Mondjahr berechnen und Mondfinsternisse voraussagen lassen.'
|
18 |
'Vorderseite: L IVL AVR SVLP ANTONINVS [LP ligiert]. Panzerbüste des Uranius Antoninus mit Lorbeerkranz in der Brustansicht nach l., Pteryges des r. Armansatzes sind zur Angabe eines erhobenen Armes waagerecht dargestellt. Rückseite: CONSERVATO-R AVG. Der Stein des Baal von Emesa auf einem Viergespann (quadriga) nach l. Auf dem Stein, der von zwei Schirmen gerahmt ist, ist das Relief eines Adlers zu sehen. Kommentar: Baldus (1971) 84 ff. 87 zur Frage der Münzstätte, ebd. 128 ff. zur Pterygesanhebung (Andeutung eines erhobenen Armes), die als alexanderhafter Gestus gilt. - Uranius Antoninus wurde im Sommer 253 n. Chr. im syrischen Emesa zum Kaiser erhoben und bewährte sich bald darauf bei der erfolgreichen Abwehr eines Einfalls der Sasaniden. Uranius Antoninus stammte möglicherweise aus der Familie der Iulia Domna, war Priester des Baals von Emesa, und ist mit dem literarisch überlieferten Sampsigeramus identisch, der als Organisator des Widerstandes gegen die Sasaniden in der Region belegt ist. Nach 254 n. Chr. fehlen Informationen über Uranius Antoninus, möglicherweise trat er nach Bereinigung der Notsituation hinter den Kaiser Valerianus zurück. Zu diesem Stück wurden 2017 im Zuge der Ausstellung Syria Antiqua zwei vergrößerte Reproduktionen (3D-Ausdrucke) erstellt, die bei den Galvanos in Schrank 81/121 liegen. Literatur: A. von Sallet, ZfN 17, 1890, 241 f. Taf. 4,9 (dieses Stück); H. R. Baldus, Uranius Antoninus (1971) 198 Nr. 85 Taf. 7,85; 12,85 (dieses Stück, mit Lit., 253/254 n. Chr. bzw. Stempelgruppe VIII ca. Dez. 253-Anfang 254 n. Chr.); RIC IV-3 Nr. 2 c; RPC IX Nr. 1940,2 Taf. 131 (dieses Stück).',
|
19 |
+
voice='romanian', #'af_ZA_google-nwu_1919', # 'serbian', 'en_US/vctk_low#p276', 'isl',
|
20 |
speed=1.14,
|
21 |
affect = True, # False = higher clarity
|
22 |
soundscape = 'dogs barg in dungeons n dragons'
|
msinference.py
CHANGED
@@ -261,9 +261,47 @@ with open(f"Utils/all_langs.csv") as f:
|
|
261 |
iso, name = line.split(",", 1)
|
262 |
TTS_LANGUAGES[iso.strip()] = name.strip()
|
263 |
# f2.write(iso + ',' + name.replace("a S","")+'\n')
|
264 |
-
|
265 |
-
|
266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
# LOAD hun / ron / serbian - rmc-script_latin / cyrillic-Carpathian (not Vlax)
|
268 |
# ==============================================================================================
|
269 |
|
@@ -313,44 +351,44 @@ def foreign(text=None, # split sentences here so we can prepend a txt for germ
|
|
313 |
speed=None):
|
314 |
|
315 |
lang = lang.lower() # https://huggingface.co/dkounadis/artificial-styletts2/blob/main/Utils/all_langs.csv
|
316 |
-
|
317 |
# https://huggingface.co/spaces/mms-meta/MMS
|
318 |
-
|
319 |
if 'hun' in lang:
|
320 |
-
|
321 |
lang_code = 'hun'
|
322 |
-
|
323 |
elif any([i in lang for i in ['ser', 'bosn', 'herzegov', 'montenegr', 'macedon']]):
|
324 |
-
|
325 |
if has_cyrillic(text): # check 0-th sentence if is cyrillic
|
326 |
-
|
327 |
lang_code = 'rmc-script_cyrillic' # romani carpathian (also has latin / cyrillic Vlax)
|
328 |
-
|
329 |
else:
|
330 |
-
|
331 |
lang_code = 'rmc-script_latin' # romani carpathian (has also Vlax)
|
332 |
-
|
333 |
elif 'rom' in lang:
|
334 |
-
|
335 |
lang_code = 'ron'
|
336 |
speed = 1.24 if speed is None else speed
|
337 |
-
|
338 |
elif 'ger' in lang:
|
339 |
-
|
340 |
lang_code = 'deu'
|
341 |
speed = 1.14 if speed is None else speed
|
342 |
-
|
343 |
elif 'alban' in lang:
|
344 |
-
|
345 |
lang_code = 'sqi'
|
346 |
speed = 1.04 if speed is None else speed
|
347 |
-
|
348 |
else:
|
349 |
-
|
350 |
lang_code = lang.split()[0].strip()
|
351 |
-
|
352 |
# Load VITS
|
353 |
-
|
354 |
net_g = VitsModel.from_pretrained(f'facebook/mms-tts-{lang_code}').eval().to(device)
|
355 |
tokenizer = VitsTokenizer.from_pretrained(f'facebook/mms-tts-{lang_code}')
|
356 |
|
@@ -376,8 +414,12 @@ def foreign(text=None, # split sentences here so we can prepend a txt for germ
|
|
376 |
_t = re.sub(r'\d+', number_to_phonemes, _t)
|
377 |
_t = fix_phones(_t)
|
378 |
|
379 |
-
elif lang_code == 'ron':
|
|
|
|
|
|
|
380 |
|
|
|
381 |
_t = _t.replace("ţ", "ț"
|
382 |
).replace('ț','ts').replace('î', 'u').replace('â','a').replace('ş','s')
|
383 |
|
@@ -390,7 +432,7 @@ def foreign(text=None, # split sentences here so we can prepend a txt for germ
|
|
390 |
|
391 |
x = net_g(input_ids=inputs.input_ids.to(device),
|
392 |
attention_mask=inputs.attention_mask.to(device),
|
393 |
-
speed = .
|
394 |
)[0, :]
|
395 |
|
396 |
# crop the 1st audio - is PREFIX text 156000 samples to chose deu voice / VitsAttention()
|
|
|
261 |
iso, name = line.split(",", 1)
|
262 |
TTS_LANGUAGES[iso.strip()] = name.strip()
|
263 |
# f2.write(iso + ',' + name.replace("a S","")+'\n')
|
264 |
+
# =============================================================================================
|
265 |
+
# R O M A N I A N N U M E R A L S
|
266 |
+
# =============================================================================================
|
267 |
+
|
268 |
+
def _ro_number(number_str):
|
269 |
+
# Function to convert numbers to their phonetic form in Romanian
|
270 |
+
# Check if the number is negative
|
271 |
+
negative = number_str.startswith('-')
|
272 |
+
if negative:
|
273 |
+
number_str = number_str[1:] # Remove the minus sign for now
|
274 |
+
|
275 |
+
# Handle floating point numbers by splitting into integer and decimal parts
|
276 |
+
if '.' in number_str:
|
277 |
+
integer_part, decimal_part = number_str.split('.')
|
278 |
+
integer_words = num2words(integer_part, lang='ro')
|
279 |
+
decimal_words = ' '.join([num2words(digit, lang='ro') for digit in decimal_part])
|
280 |
+
result = f"{integer_words} virgulă {decimal_words}"
|
281 |
+
else:
|
282 |
+
result = num2words(number_str, lang='ro')
|
283 |
+
|
284 |
+
# Add 'minus' if the number is negative
|
285 |
+
if negative:
|
286 |
+
result = "minus " + result
|
287 |
+
|
288 |
+
return result
|
289 |
+
|
290 |
+
def romanian_num2str(input_string):
|
291 |
+
# Function to convert a string with numbers to phonetic representation in Romanian
|
292 |
+
# Regex pattern to identify numbers in the string (including negative numbers, decimals)
|
293 |
+
pattern = r'-?\d+(\.\d+)?'
|
294 |
+
|
295 |
+
def replace_with_phoneme(match):
|
296 |
+
# Extract the matched number and convert it to phonetic representation
|
297 |
+
number_str = match.group()
|
298 |
+
return _ro_number(number_str)
|
299 |
+
|
300 |
+
# Use regex to find all numbers in the input string and replace them with their phonetic form
|
301 |
+
return re.sub(pattern, replace_with_phoneme, input_string)
|
302 |
+
|
303 |
+
|
304 |
+
# ==============================================================================================
|
305 |
# LOAD hun / ron / serbian - rmc-script_latin / cyrillic-Carpathian (not Vlax)
|
306 |
# ==============================================================================================
|
307 |
|
|
|
351 |
speed=None):
|
352 |
|
353 |
lang = lang.lower() # https://huggingface.co/dkounadis/artificial-styletts2/blob/main/Utils/all_langs.csv
|
354 |
+
|
355 |
# https://huggingface.co/spaces/mms-meta/MMS
|
356 |
+
|
357 |
if 'hun' in lang:
|
358 |
+
|
359 |
lang_code = 'hun'
|
360 |
+
|
361 |
elif any([i in lang for i in ['ser', 'bosn', 'herzegov', 'montenegr', 'macedon']]):
|
362 |
+
|
363 |
if has_cyrillic(text): # check 0-th sentence if is cyrillic
|
364 |
+
|
365 |
lang_code = 'rmc-script_cyrillic' # romani carpathian (also has latin / cyrillic Vlax)
|
366 |
+
|
367 |
else:
|
368 |
+
|
369 |
lang_code = 'rmc-script_latin' # romani carpathian (has also Vlax)
|
370 |
+
|
371 |
elif 'rom' in lang:
|
372 |
+
|
373 |
lang_code = 'ron'
|
374 |
speed = 1.24 if speed is None else speed
|
375 |
+
|
376 |
elif 'ger' in lang:
|
377 |
+
|
378 |
lang_code = 'deu'
|
379 |
speed = 1.14 if speed is None else speed
|
380 |
+
|
381 |
elif 'alban' in lang:
|
382 |
+
|
383 |
lang_code = 'sqi'
|
384 |
speed = 1.04 if speed is None else speed
|
385 |
+
|
386 |
else:
|
387 |
+
|
388 |
lang_code = lang.split()[0].strip()
|
389 |
+
|
390 |
# Load VITS
|
391 |
+
|
392 |
net_g = VitsModel.from_pretrained(f'facebook/mms-tts-{lang_code}').eval().to(device)
|
393 |
tokenizer = VitsTokenizer.from_pretrained(f'facebook/mms-tts-{lang_code}')
|
394 |
|
|
|
414 |
_t = re.sub(r'\d+', number_to_phonemes, _t)
|
415 |
_t = fix_phones(_t)
|
416 |
|
417 |
+
elif lang_code == 'ron':
|
418 |
+
|
419 |
+
# numerals
|
420 |
+
_t = romanian_num2str(_t)
|
421 |
|
422 |
+
# tone
|
423 |
_t = _t.replace("ţ", "ț"
|
424 |
).replace('ț','ts').replace('î', 'u').replace('â','a').replace('ş','s')
|
425 |
|
|
|
432 |
|
433 |
x = net_g(input_ids=inputs.input_ids.to(device),
|
434 |
attention_mask=inputs.attention_mask.to(device),
|
435 |
+
speed = 1.14 + .44 * np.random.rand() # variable speed / sentence
|
436 |
)[0, :]
|
437 |
|
438 |
# crop the 1st audio - is PREFIX text 156000 samples to chose deu voice / VitsAttention()
|