Skip to content

Commit

Permalink
Merge pull request #12 from GOTHIC3020/main
Browse files Browse the repository at this point in the history
Spelling corrections Closes #10
  • Loading branch information
h43lb1t0 authored Feb 4, 2025
2 parents 89334fd + 82fc918 commit 599a922
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ def voice_preview():

def ui():
info_voice = """Select a Voice. \nThe default voice is a 50-50 mix of Bella & Sarah\nVoices starting with 'a' are American
englisch, voices with 'b' are British englisch"""
english, voices with 'b' are British english"""
with gr.Accordion("Kokoro"):
voice = gr.Dropdown(choices=VOICES, value=VOICES[0], label="Voice", info=info_voice, interactive=True)

preview = gr.Button("Voice preview", type="secondary")

preview_output = gr.HTML()

info_splitting ="""Kokoro only supports 510 tokens. One method to split the text is by sentance (default), the otherway
info_splitting ="""Kokoro only supports 510 tokens. One method to split the text is by sentence (default), the otherway
is by word up to 510 tokens. """
spltting_method = gr.Radio(["Split by Sentance", "Split by Word"], info=info_splitting, value="Split by Sentance", label_lines=2, interactive=True)
spltting_method = gr.Radio(["Split by sentence", "Split by Word"], info=info_splitting, value="Split by sentence", label_lines=2, interactive=True)


voice.change(voice_update, voice)
Expand Down
20 changes: 10 additions & 10 deletions src/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def download_kokoro_weights():

snapshot_path = download_kokoro_weights()

# Download the models for sentance splitting
# Download the models for sentence splitting
nltk.download('punkt')
nltk.download('punkt_tab')

Expand Down Expand Up @@ -106,22 +106,22 @@ def run(text, preview=False):

return msg_id

sentance_based = True
sentence_based = True

def set_plitting_type(method="Split by Sentance"):
def set_plitting_type(method="Split by sentence"):
"""Set the splitting method for the text.
Args:
method (str, optional): The splitting method. Defaults to "Split by Sentance".
method (str, optional): The splitting method. Defaults to "Split by sentence".
"""
global sentance_based
sentance_based = True if method == "Split by Sentance" else False
print(f'Splitting method: {"Sentance" if sentance_based else "Word"}')
global sentence_based
sentence_based = True if method == "Split by sentence" else False
print(f'Splitting method: {"sentence" if sentence_based else "Word"}')

set_plitting_type()

def split_text(text):
"""Split the text into chunks of sentances or word up to 510 token.
"""Split the text into chunks of sentences or word up to 510 token.
Args:
text (str): The text to split.
Expand All @@ -133,7 +133,7 @@ def split_text(text):
global MODEL

max_token = 510
text_parts = sent_tokenize(text) if sentance_based else text.split()
text_parts = sent_tokenize(text) if sentence_based else text.split()
current_text_parts = []
chunks = []
current_chunk_len = 0
Expand Down Expand Up @@ -221,4 +221,4 @@ def concatenate_audio_segments(segments):
return audio_segment

if __name__ == '__main__':
run("Hello, this is an example of a text for Kokoro")
run("Hello, this is an example of a text for Kokoro")

0 comments on commit 599a922

Please sign in to comment.