Skip to content

Commit 472c341

Browse files
committed
Add Hungarian number to words converter
This commit introduces a new module `num2words_hu.py` that implements a number to words converter for the Hungarian language. The module includes functionality for converting cardinal numbers, ordinal numbers, years, and currency values into their Hungarian verbal representations. It builds upon a base class for European number conversion and includes specific adaptations for Hungarian linguistic rules and currency formats.
1 parent ccde914 commit 472c341

File tree

5 files changed

+1103
-125
lines changed

5 files changed

+1103
-125
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pip install num2words
9191
>
9292
> ```bash
9393
> git clone https://github.com/SWivid/F5-TTS.git
94-
> cd F5-TTS
94+
> cd F5-TTS_hun
9595
> # git submodule update --init --recursive # (optional, if need > bigvgan)
9696
> pip install -e .
9797
> ```

src/f5_tts/infer/infer_gradio.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# ruff: noqa: E402
2-
# Above allows ruff to ignore E402: module level import not at top of file
3-
41
import gc
52
import json
6-
import os # needed for normaliser folder reading
3+
import os
74
import re
85
import tempfile
96
from collections import OrderedDict
@@ -46,6 +43,12 @@ def gpu_decorator(func):
4643
from f5_tts.model import DiT, UNetT
4744

4845

46+
# Define the absolute path to the normalisers directory relative to this script.
47+
# This makes the script independent of the current working directory.
48+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
49+
NORMALISERS_DIR = os.path.join(SCRIPT_DIR, "normalisers")
50+
51+
4952
DEFAULT_TTS_MODEL = "F5-TTS_v1"
5053
tts_model_choice = DEFAULT_TTS_MODEL
5154

@@ -58,14 +61,13 @@ def gpu_decorator(func):
5861

5962
def get_normaliser_choices():
6063
"""
61-
Scan the ./normalisers folder for subfolders that contain a normaliser.py file.
62-
Returns a list of possible normaliser choices.
64+
Scan the normalisers folder (relative to this script) for subfolders
65+
that contain a normaliser.py file. Returns a list of possible normaliser choices.
6366
"""
64-
normaliser_path = "./normalisers"
6567
choices = []
66-
if os.path.exists(normaliser_path) and os.path.isdir(normaliser_path):
67-
for item in os.listdir(normaliser_path):
68-
subdir = os.path.join(normaliser_path, item)
68+
if os.path.exists(NORMALISERS_DIR) and os.path.isdir(NORMALISERS_DIR):
69+
for item in os.listdir(NORMALISERS_DIR):
70+
subdir = os.path.join(NORMALISERS_DIR, item)
6971
if os.path.isdir(subdir) and os.path.exists(os.path.join(subdir, "normaliser.py")):
7072
choices.append(item)
7173
return choices
@@ -315,7 +317,8 @@ def basic_tts(
315317
# -- Normaliser step --
316318
processed_text = gen_text_input
317319
if normaliser_choice_input != "None":
318-
normaliser_file = os.path.join("normalisers", normaliser_choice_input, "normaliser.py")
320+
# Use the absolute path defined at the start of the script
321+
normaliser_file = os.path.join(NORMALISERS_DIR, normaliser_choice_input, "normaliser.py")
319322
if os.path.exists(normaliser_file):
320323
try:
321324
import importlib.util
@@ -673,7 +676,8 @@ def generate_multistyle_speech(
673676
# -- Load normaliser module if chosen --
674677
normaliser_module = None
675678
if normaliser_choice != "None":
676-
normaliser_file = os.path.join("normalisers", normaliser_choice, "normaliser.py")
679+
# Use the absolute path defined at the start of the script
680+
normaliser_file = os.path.join(NORMALISERS_DIR, normaliser_choice, "normaliser.py")
677681
if os.path.exists(normaliser_file):
678682
try:
679683
import importlib.util
@@ -1072,7 +1076,7 @@ def chat_pipeline(conv_state, audio_path, text_msg, system_prompt, ref_audio, re
10721076
with gr.Blocks() as app:
10731077
gr.Markdown(
10741078
f"""
1075-
# E2/F5 TTS
1079+
# E2/F5 TTS_hun normalizálóval ellátott változata
10761080
10771081
This is {"a local web UI for [F5 TTS](https://github.com/SWivid/F5-TTS)" if not USING_SPACES else "an online demo for [F5-TTS](https://github.com/SWivid/F5-TTS)"} with advanced batch processing support. This app supports the following TTS models:
10781082
@@ -1187,8 +1191,8 @@ def set_custom_model(custom_ckpt_path, custom_vocab_path, custom_model_cfg_str):
11871191
global_choose_normaliser = gr.Radio(
11881192
choices=["None"] + normaliser_choices_list,
11891193
label="Choose Text Normaliser (Global for Basic/Multi-Speech)",
1190-
value="None",
1191-
info="Applies to text in 'Basic-TTS' and 'Multi-Speech' tabs. Requires normaliser.py in ./normalisers/<name>/ folder."
1194+
value="hun" if "hun" in normaliser_choices_list else "None",
1195+
info="Applies to text in 'Basic-TTS' and 'Multi-Speech' tabs. Looks for normaliser.py in <script_dir>/normalisers/<name>/ folder."
11921196
)
11931197

11941198

@@ -1312,4 +1316,4 @@ def main(port, host, share, api, root_path, inbrowser):
13121316
if not USING_SPACES:
13131317
main()
13141318
else:
1315-
app.queue().launch()
1319+
app.queue().launch()

src/f5_tts/infer/normalisers/hun/changes.csv

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ geneieve, dzsenív
2929
boimler, bojler
3030
one, egy
3131
two, kettő
32+
microsoft, mikroszoft
33+
malware, malvér
3234
gpu, gépéú
3335
openai, openéáj
3436
deepseek, dípszík
@@ -753,3 +755,120 @@ Fidelis,Fidélisz
753755
Gót,Gót
754756
Kobra,Kobra
755757
Kurtz,Kurc
758+
FBI,efbíáj
759+
CIA,sziáéj
760+
NASA,náza
761+
UN,uenn
762+
EU,eu
763+
NATO,nátó
764+
USA,júeszéj
765+
UK,júkéj
766+
UFO,ufó
767+
NBA,enbíéj
768+
NFL,enefel
769+
BBC,bíbiszí
770+
CNN,szíenen
771+
IT,ájti
772+
AI,éjáj
773+
CEO,szííó
774+
GPS,dzsípíesz
775+
LED,led
776+
RAM,ram
777+
ROM,rom
778+
WWW, vévévé
779+
ZIP,zip
780+
PIN,pin
781+
ID,ájdí
782+
LAN,lan
783+
WiFi,vifi
784+
ASAP,éjszep
785+
DIY,doitjuorszelf
786+
FAQ,fakú
787+
BRB,bíárbí
788+
BTW,bájthevéj
789+
LOL,lol
790+
OMG,óemdzsi
791+
IDK,ájdíkéj
792+
IQ,ikú
793+
EQ,ekú
794+
PR,píár
795+
GIF,gif
796+
JPEG,jpeg
797+
CSGO,cségó
798+
MAC,mek
799+
PC,pécé
800+
BIOS,biosz
801+
DOS,dosz
802+
GUI,gui
803+
SATA,sata
804+
RAID,réd
805+
JSON,dzséjszon
806+
XML,ikszemel
807+
API,api
808+
PhD,pí-ejcs-dí
809+
CV,szíví
810+
CFO,szíefó
811+
COO,szíóó
812+
CTO,szítíó
813+
R&D,áren-dí
814+
B2B,bí-tú-bí
815+
B2C,bí-tú-szí
816+
CRM,szíárem
817+
ERP,íárpí
818+
KPI,kéjpíáj
819+
OKR,óukéjár
820+
ROI,ároj
821+
VoIP,vóip
822+
CAD,ked
823+
CAM,kem
824+
CAE,szíéjí
825+
SCM,esz-szí-em
826+
BPM,bí-pí-em
827+
IPO,ájpíó
828+
ETF,í-tí-ef
829+
GDP,dzsí-dí-pí
830+
VAT,víéjtí
831+
IRS,ájáresz
832+
DEA,dííéj
833+
NSA,eneszéj
834+
DHS,díéjcsesz
835+
DoD,díoudí
836+
AFK,éjefkéj
837+
NPC,enpíszí
838+
RPG,árpídzsí
839+
HUD,hád
840+
DLC,díelszí
841+
SDK,eszdíkéj
842+
DBMS,díbíemesz
843+
IoT,ájótí
844+
ML,emel
845+
DL,díel
846+
NLP,enelpí
847+
DDR,dídídár
848+
PSU,píeszjú
849+
CDN,szídíen
850+
TOS,tíóesz
851+
EULA,júlá
852+
GDPR,dzsídípíár
853+
HIPAA,hipá
854+
DMCA,díemszéj
855+
ACL,éjszíel
856+
IPSec,ájpíszek
857+
SQLi,esz-kjú-el-áj
858+
XSS,ekszesz
859+
CSRF,szíeszáref
860+
MITM,emájtíem
861+
ICU,ájszjú
862+
CPR,szípíár
863+
HIV,hív
864+
AIDS,éjdz
865+
DNA,díéjenéj
866+
RNA,árenéj
867+
BMI,bíemáj
868+
CDC,szídíszí
869+
EMT,íemtí
870+
MRSA,emerszá
871+
MRI,emáráj
872+
CT,szítí
873+
X-ray,ekszréj
874+
ADHD,éjdíéjcsdí

0 commit comments

Comments
 (0)