{"id":15227110,"url":"https://github.com/netherquartz/textforspeechnormalizer","last_synced_at":"2025-04-09T23:42:02.647Z","repository":{"id":164871142,"uuid":"604831192","full_name":"NetherQuartz/TextForSpeechNormalizer","owner":"NetherQuartz","description":"A Python library to accentuate Russian text","archived":false,"fork":false,"pushed_at":"2024-12-19T00:40:09.000Z","size":16844,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T09:09:36.679Z","etag":null,"topics":["accentuation","asr","nlp","python","russian","russian-language","stt","tts"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NetherQuartz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-02-21T22:05:25.000Z","updated_at":"2025-03-05T02:36:24.000Z","dependencies_parsed_at":"2023-09-07T03:22:10.318Z","dependency_job_id":null,"html_url":"https://github.com/NetherQuartz/TextForSpeechNormalizer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetherQuartz%2FTextForSpeechNormalizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetherQuartz%2FTextForSpeechNormalizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetherQuartz%2FTextForSpeechNormalizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetherQuartz%2FTextForSpeechNormalizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NetherQuartz","download_url":"https://codeload.github.com/NetherQuartz/TextForSpeechNormalizer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131470,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accentuation","asr","nlp","python","russian","russian-language","stt","tts"],"created_at":"2024-09-28T22:05:14.851Z","updated_at":"2025-04-09T23:42:02.624Z","avatar_url":"https://github.com/NetherQuartz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Automatic accentuation for texts in Russian\n\nAccentuation is a common task in such speech-related fields as text-to-speech, speech recognition and language learning. This library is used to mark stressed vowels in given texts using the data from Wiktionary and syntactic analysis of [Spacy](https://github.com/explosion/spaCy).\n\n### Installation\nPython 3.10 and above supported.\n```bash\npip install tsnorm\n```\n\n### General usage\n```Python\nfrom tsnorm import Normalizer\n\n\nnormalizer = Normalizer(stress_mark=chr(0x301), stress_mark_pos=\"after\")\nnormalizer(\"Словно куклой в час ночной теперь он может управлять тобой\")\n\n# Output: Сло́вно ку́клой в час ночно́й тепе́рь он мо́жет управля́ть тобо́й\n```\n\n### Change stress mark and its position\n```Python\nnormalizer = Normalizer(stress_mark=\"+\", stress_mark_pos=\"before\")\nnormalizer(\"Трупы оживали, землю разрывали\")\n\n# Output: Тр+упы ожив+али, з+емлю разрыв+али\n```\n\n### Stress yo (Ё)\n```Python\nnormalizer = Normalizer(stress_mark=\"+\", stress_mark_pos=\"before\", stress_yo=True)\nnormalizer(\"Погаснет день, луна проснётся, и снова зверь во мне очнётся\")\n\n# Output: Пог+аснет день, лун+а просн+ётся, и сн+ова зверь во мне очн+ётся\n```\n\n### Stress monosyllabic words\n```Python\nnormalizer = Normalizer(stress_mark=\"+\", stress_mark_pos=\"before\", stress_monosyllabic=True)\nnormalizer(\"Панки грязи не боятся, кто устал — ушёл сдаваться!\")\n\n# Output: П+анки гр+язи н+е бо+ятся, кт+о уст+ал — ушёл сдав+аться!\n```\n\n### Change minimum length of words to be stressed\n```Python\nnormalizer = Normalizer(stress_mark=\"+\", stress_mark_pos=\"before\", stress_monosyllabic=True)\nnormalizer(\"Разбежавшись, прыгну со скалы, вот я был и вот меня не стало\")\n\n# Output: Разбеж+авшись, пр+ыгну с+о скал+ы, в+от +я б+ыл +и в+от мен+я н+е ст+ало\n\n\nnormalizer = Normalizer(stress_mark=\"+\", stress_mark_pos=\"before\", stress_monosyllabic=True, min_word_len=2)\nnormalizer(\"Разбежавшись, прыгну со скалы, вот я был и вот меня не стало\")\n\n# Output: Разбеж+авшись, пр+ыгну с+о скал+ы, в+от я б+ыл и в+от мен+я н+е ст+ало\n\n\nnormalizer = Normalizer(stress_mark=\"+\", stress_mark_pos=\"before\", stress_monosyllabic=True, min_word_len=3)\nnormalizer(\"Разбежавшись, прыгну со скалы, вот я был и вот меня не стало\")\n\n# Output: Разбеж+авшись, пр+ыгну со скал+ы, в+от я б+ыл и в+от мен+я не ст+ало\n```\n\n### Expand normalizer dictionary\n\n```Python\nfrom tsnorm import Normalizer, CustomDictionary, WordForm, Lemma, WordFormTags, LemmaPOS\n\n\nnormalizer = Normalizer(\"+\", \"before\")\n\nnormalizer(\"Охотник Себастьян, что спал на чердаке\")\n# Output: Ох+отник Себастьян, что спал на чердак+е\n\ndictionary = CustomDictionary(\n    word_forms=[\n        WordForm(\"Себастьян\", 7, WordFormTags(singular=True, nominative=True), \"Себастьян\")\n    ],\n    lemmas=[\n        Lemma(\"Себастьян\", LemmaPOS(PNOUN=True))\n    ]\n)\n\nnormalizer.update_dictionary(dictionary)\n\nnormalizer(\"Охотник Себастьян, что спал на чердаке\")\n# Output: Ох+отник Себасть+ян, что спал на чердак+е\n```\n\nIt's also possible to pass `CustomDictionary` at normalizer initialization:\n```Python\nnormalizer = Normalizer(\"+\", \"before\", custom_dictionary=dictionary)\n```\n\nTo add your custom words to normalizer dictionary you must pass two lists to `CustomDictionary`:\n1. a list of `WordForm` objects, which are forms of each word with case, tense and lemma information, as well as the positions of stressed letters,\n2. a list of `Lemma` objects, which are records of lemmas with their parts of speech.\n\nParts of speech for lemmas are configured using the `LemmaPOS` class which stores [universal POS tags](https://universaldependencies.org/u/pos/).\n\n## Acknowledgement\n\nThis library is based on code by @einhornus from his [article](https://habr.com/ru/articles/575100/) on Habr.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetherquartz%2Ftextforspeechnormalizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetherquartz%2Ftextforspeechnormalizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetherquartz%2Ftextforspeechnormalizer/lists"}