Repository navigation
fix(tokenize): keep non-English abbreviations in one sentence in blingfire - #8932
Open
dorukdumlu wants to merge 3 commits into
Open
dorukdumlu wants to merge 3 commits into
dorukdumlu wants to merge 3 commits into
Conversation
…ailing boundary "ir" (Spanish/Portuguese "to go") and "os" (French "bone") end sentences in other languages. A boundary with nothing after it is kept, so the last sentence still has its newlines normalized.
…abbreviation in the sentence A stream chunk that ends in "Cad. " returned the space as a token of its own, and BufferedTokenStream committed "... Cad." before the rest of the address.
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8931
Summary
blingfire (the default sentence tokenizer in
tts_node,StreamAdapterand most TTS plugins) ends a sentence after abbreviations that other languages put before a name, a street or a number, so TTS getsKartınız Bağdat Cad.andNo: 12 Kadıköy adresine gönderildi.as two sentences. English (Dr. Smith,Main St. Suite 200) and French are not affected._split_sentencesnow drops a blingfire boundary when the word before the period is one of a short list of these abbreviations, the same way it already adds a boundary after a danda:Doç Uzm Yrd Öğr Arş Müh(titles),Cad Cd Sok Sk Mah Mh Blv(addresses)Dra Lic Ing Dña Avda Pza Ctra, PortugueseDra Pç, ItalianDott Avv Ing, Dutchdhr mevr mw mr, Polishinż ul, GermanHrnThe list holds only abbreviations blingfire splits after (measured in the issue). The match is case-sensitive, on the whole word, plus the capitalised form of the lowercase entries. A boundary with nothing after it is kept. Left out on purpose, because they can end a sentence:
Hz(also hertz),Ud.,Rod(a name), Dutchir(Spanish and Portuguese "to go"), Polishos(French "bone").Kartınız Bağdat Cad. No: 12 Kadıköy adresine gönderildi.Cad.Su cita con la Dra. Martínez es en la Avda. Diagonal mañana.Uw afspraak met dhr. Jansen is morgen om tien uur precies.dhr.The signal runs at 50 Hz. Then it stops.Toplantı yeri İstanbul. Yarın görüşürüz.Cost: 53 → 66 µs per
_split_sentencescall on a 453-character reply.Testing
tests/test_tokenizer.py: one case per language (all failed before the change), counter-cases that must still split (an ordinary word,Hz,İstanbulending inul, Spanishir., Frenchos.), a last sentence ending in an abbreviation (newlines still normalized), and two streamed tests with thetts_nodesettings (retain_format=True): chunks that start with a space, and a chunk that ends inCad.StreamAdapter: 604 passeduv run pytest --unit --audio_eot: no new failures compared tomain(on Windows,test_hosted_logs,test_roomand a few others fail on both)ruff format,ruff check,mypy --platform linux -p livekit.agents