- Notifications
You must be signed in to change notification settings - Fork0
Convert english phrases into phonetic japanese kana approximations; also known as Englishru.
License
Luigi-Pizzolito/English2KanaTransliteration
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Convert English phrases into phonetic Japanese kana approximations; also known as Englishru. Does not translate English into Japanese, but translates English words into their approximate pronounciations in Japanese.
Based on the English to Katakana transcription code written in Python byYoko Harada (@yokolet) Please see that repo for details on the phonetic conversion.
English to phoneme conversion based onCMUDict. Kanji to Katakana convertion based onKANJIDIC2. Thanks toJMDict andkana. Please refer to those licenses for non-free implementations.
It is a port in Golang with some additional functions:
- Filtering functions to split, parse, and rejoin sentences which contain punctuation or improper contractions.
- Alsoaccepts Japanese input; converts any Kanji characters into their most common Hiragana pronounciation, converts Hiragana into Katakana, leaves Katakana as is.
- Alsoaccepts Romaji input.
- strict input cleaning mode for use with TTS input that does not understand punctuation and other chars. See header below.
Below is an example go file to test this module. It reads input fromstdin
, converts the English sentences into their Japanese transliteration and prints them tostdout
.
package mainimport ("github.com/Luigi-Pizzolito/English2KanaTransliteration""bufio""fmt""os")funcmain() {// Create an instance of AllToKanaallToKana:=kanatrans.NewAllToKana()// Listen to stdin indefinitelyreader:=bufio.NewReader(os.Stdin)for {line,err:=reader.ReadString('\n')iferr!=nil {break// Exit loop on error}// Call convertString function with the accumulated lineresult:=allToKana.Convert(line)// Output the resultfmt.Print(result+"\n")}}
Sample Output:
❯ go run .Hello there.ヘロー ゼアー。With this program, you can make Japanese text to speech speak in English!ウィズ ジス プローラ、 ユー キャン メイク ジャーンイーズ テックスト ツー スピーチ スピーク イン イングシュ!watashi wa miku desu~ワタシ ワ ミク デス〜Hello! こんにちは~ ヘロー, miki松原。ヘロー! コンニチハ〜 ヘロー、 ミキショウゲン。
// Create an instance of AllToKanaallToKana:=kanatrans.NewAllToKana()// Usagekana:=allToKana.Convert("Hello! watashiwa 初音ミク.")// -> ヘロー! ワタシワ ショオンミク。
// Create an instance of EngToKanaengToKana:=kanatrans.NewEngToKana()// Usagekana:=engToKana.TranscriptSentence("Hello World!")// -> ヘローワールド
// Create an instance of KanjiToKanakanjiToKana:=kanatrans.NewKanjiToKana()// Usagekana:=kanjiToKana.Convert("初音")// -> ショオン
This needs some work, it just takes the most common pronouciation of each Kanji instead of the correct one for the context. Pull requests are welcome!
// Create an instance of HiraganaToKanahiraganaToKana:=kanatrans.NewHiraganaToKana()// Usagekana:=hiraganaToKana.Convert("こんにちは")// -> コンニチハ
// Create an instance of RomajiToKanaromajiToKana:=kanatrans.NewRomajiToKana()// Usagekana:=romajiToKana.Convert("kita kita desu")// -> キタ キタ デス
// UsagejapanesePunctuation:=kanatrans.ConvertToJapanesePunctuation("Hello, World!")// -> Hello、 World!
This module is intended to allow TTS which only support Japanese to speak english (such as AquesTalk, Softalk, etc). These TTS usually have some limitations in what punctuation may be present in the input; with only commas and stops being interpreted as a pause and all other punctuation causing an error.
To use this module for such TTS input, you may enablestrict input cleaning mode (only Japanese comma and stop on output) by passing a bool in the initialiser forEngToKana
,RomajiToKana
andAllToKana
classes:
// Create an instance of AllToKana with strict punctuation outputallToKana:=kanatrans.NewAllToKana(true)
// Create an instance of EngToKana with strict punctuation outputengToKana:=kanatrans.NewEngToKana(true)
// Create an instance of RomajiToKana with strict punctuation outputromajiToKana:=kanatrans.NewRomajiToKana(true)
You may also use the functionkanatrans.ConvertToJapanesePunctuationRestricted
instead ofkanatrans.ConvertToJapanesePunctuation
.
Internally, theAllToKana
proccess function uses aKanjiSplitter
class to callfunc(string) string
functions which handle Kanji, Kana, English and Punctuation respectively:
// Create an instance of KanjiSplitter with proccesing callbackskanjiSplitter:=kanatrans.NewKanjiSplitter(kanjiToKana.Convert,// Kanji callbackhiraganaToKana.Convert,// Gana & Kana callbackengToKana.TranscriptSentence,// English callbackConvertToJapanesePunctuation,// Punctuation callback)
If required, you may use aKanjiSplitter
with custom callback functions to provide different processing.
About
Convert english phrases into phonetic japanese kana approximations; also known as Englishru.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.