-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to extract voicename (#29)
* Add support to extract voicename * Add more tests and Add Custom voice tag parser logic * Fix comments * Fix test fail due to incorrect end tag * Improve test coverage * Fix names * Add test * Use html tokenizer for parsing voice tags * Unexport the ParseTextWebVTT and use internal test
- Loading branch information
Showing
5 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package astisub | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseTextWebVTT(t *testing.T) { | ||
|
||
t.Run("When both voice tags are available", func(t *testing.T) { | ||
testData := `<v Bob>Correct tag</v>` | ||
|
||
s := parseTextWebVTT(testData) | ||
assert.Equal(t, "Bob", s.VoiceName) | ||
assert.Equal(t, 1, len(s.Items)) | ||
assert.Equal(t, "Correct tag", s.Items[0].Text) | ||
}) | ||
|
||
t.Run("When there is no end tag", func(t *testing.T) { | ||
testData := `<v Bob> Text without end tag` | ||
|
||
s := parseTextWebVTT(testData) | ||
assert.Equal(t, "Bob", s.VoiceName) | ||
assert.Equal(t, 1, len(s.Items)) | ||
assert.Equal(t, "Text without end tag", s.Items[0].Text) | ||
}) | ||
|
||
t.Run("When the end tag is correct", func(t *testing.T) { | ||
testData := `<v Bob>Incorrect end tag</vi>` | ||
|
||
s := parseTextWebVTT(testData) | ||
assert.Equal(t, "", s.VoiceName) | ||
assert.Equal(t, 0, len(s.Items)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters