feat: implemented audiogen
This commit is contained in:
52
test_main.py
Normal file
52
test_main.py
Normal file
@ -0,0 +1,52 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from main import SimpleMarkupParser
|
||||
|
||||
|
||||
|
||||
class Test(TestCase):
|
||||
def test_simple_markup_parser_0(self):
|
||||
# Test case with sections
|
||||
markup_text = "[section 1] [voice alloy] Hello, this is section 1. [end_section] [voice nova] Now we're outside the section. [insert_section 1]"
|
||||
parser = SimpleMarkupParser(markup_text)
|
||||
parser.parse()
|
||||
parsed_output = parser.get_output()
|
||||
|
||||
assert len(parsed_output) == 7, "Expected 7 tokens, got %d" % len(parsed_output)
|
||||
assert parsed_output[0] == {'type': 'section_start', 'section_id': 1}
|
||||
assert parsed_output[1] == {'type': 'voice', 'voice': 'alloy'}
|
||||
assert parsed_output[2] == {'type': 'text', 'text': 'Hello, this is section 1.'}
|
||||
assert parsed_output[3] == {'type': 'section_end'}
|
||||
assert parsed_output[4] == {'type': 'voice', 'voice': 'nova'}
|
||||
assert parsed_output[5] == {'type': 'text', 'text': "Now we're outside the section."}
|
||||
assert parsed_output[6] == {'type': 'insert_section', 'section_id': 1}
|
||||
|
||||
|
||||
def test_simple_markup_parser_1(self):
|
||||
# Test case with silence
|
||||
markup_text = "[voice nova] Let's have a moment of silence. [silence 3s] And we're back!"
|
||||
parser = SimpleMarkupParser(markup_text)
|
||||
parser.parse()
|
||||
parsed_output = parser.get_output()
|
||||
|
||||
assert len(parsed_output) == 4
|
||||
assert parsed_output[0] == {'type': 'voice', 'voice': 'nova'}
|
||||
assert parsed_output[1] == {'type': 'text', 'text': "Let's have a moment of silence."}
|
||||
assert parsed_output[2] == {'type': 'silence', 'duration': 3000}
|
||||
assert parsed_output[3] == {'type': 'text', 'text': "And we're back!"}
|
||||
|
||||
def test_simple_markup_parser_2(self):
|
||||
# Test case with unknown markup
|
||||
markup_text = "[voice fable] Hello! [unknown_markup] This is an unknown markup. [voice nova] Back to a known voice."
|
||||
parser = SimpleMarkupParser(markup_text)
|
||||
parser.parse()
|
||||
parsed_output = parser.get_output()
|
||||
|
||||
assert len(parsed_output) == 6
|
||||
assert parsed_output[0] == {'type': 'voice', 'voice': 'fable'}
|
||||
assert parsed_output[1] == {'type': 'text', 'text': 'Hello!'}
|
||||
assert parsed_output[2] == {'type': 'none', 'text': '[unknown_markup]'}
|
||||
assert parsed_output[3] == {'type': 'text', 'text': 'This is an unknown markup.'}
|
||||
assert parsed_output[4] == {'type': 'voice', 'voice': 'nova'}
|
||||
assert parsed_output[5] == {'type': 'text', 'text': 'Back to a known voice.'}
|
||||
|
Reference in New Issue
Block a user