nongeneric/lsd2dsl

[feature request] LSA --> OGG

Closed this issue · 9 comments

Как я понимаю, LSA представляет собой, грубо говоря, один большой OGG, а раз так, то нельзя ли добавить такую опцию, чтобы звуки извлекались прямо в виде маленьких оггов? Если его можно разрезать на кусочки без пережатия и потери качества, то такие огги занимали бы гораздо меньше места и их можно было бы сразу использовать в GoldenDict.

Вообще GoldenDict вполне переваривает LSA безо всяких конвертаций.

А так да, один большой OGG файл. Есть правда нюанс, что OGG состоит из пакетов, а в каждом пакете определенное количество сэмплов. И вроде бы начало файла часто оказывается посреди пакета. Я не вникал в устройство OGG и не могу сказать насколько этот факт усложнит lossless разрезание файла, но когда я это заметил, решил, что OGG мне не сильно нужен, и проще будет ограничиться WAV.

Я думаю если будут какие-то ещё сценарии кроме GoldenDict, то можно подумать.

Вообще GoldenDict вполне переваривает LSA безо всяких конвертаций.

А я про это совсем забыл. Закрываю, извините за беспокойство.

Вообще GoldenDict вполне переваривает LSA безо всяких конвертаций.

А так да, один большой OGG файл. Есть правда нюанс, что OGG состоит из пакетов, а в каждом пакете определенное количество сэмплов. И вроде бы начало файла часто оказывается посреди пакета. Я не вникал в устройство OGG и не могу сказать насколько этот факт усложнит lossless разрезание файла, но когда я это заметил, решил, что OGG мне не сильно нужен, и проще будет ограничиться WAV.

Я думаю если будут какие-то ещё сценарии кроме GoldenDict, то можно подумать.

I am developing https://github.com/FreeLanguageTools/ssmtool, and it would be nice to be able to use Lingvo's files. However the wav files are too big compared to oggs. I tried using the tool in stardict-tools but they seem to produce bad results. It would be nice if this tool can produce oggs for easier distribution

Well, I couldn't figure out how to produce OGG files without doing lossy re-encoding, but I'll keep the issue open.
Just curious, why can't you use LSA directly? The format is simple enough.

@nongeneric
I'm not sure what the format actually is. From a hex editor it seems like there is a header with each of the named files, and then a giant OGG file. Though, my main issue is that these are often named as a number rather than the word, which would require it to be linked from a lingvo dictionary. But if I want to use other dictionaries too, I need it to be able to convert the names in advance.

Also, i think the this file shows how to split the ogg up: https://github.com/huzheng001/stardict-3/blob/master/tools/src/lingvosound2resdb.cpp. However, it seems to do it incorrectly; the total number of sounds is off by a few and the index doesn't match the one in the dsl.

lingvosound2resdb uses sox to split the giant OGG file. I'm not familiar enough with the OGG format to do the same in my code and don't want a sox dependency.

I'm not sure what you mean by indexes and linking from a Lingvo dictionary. The references from LSD/DSL dictionaries are done via string names and not indexes of any sort.

If you want the real sound names, then you just need to parse the LSA header the way I did inside LSAReader::collectHeadings(). Keep in mind that Lingvo LSA's sometimes contain duplicate names, and they can have special characters in their names, which makes it a pain to save them to disk on Windows.

AFAIK GoldenDict plays sounds from LSA by first decoding a range of samples from the OGG file into a temporary WAV file and then plays it using an external audio player. You could probably do the same. It would save you the trouble of extracting/splitting LSA.

If you want the real sound names, then you just need to parse the LSA header the way I did inside LSAReader::collectHeadings(). Keep in mind that Lingvo LSA's sometimes contain duplicate names, and they can have special characters in their names, which makes it a pain to save them to disk on Windows.
Is this able to recover the actual words as the filename? I can also attempt to save the mapping somewhere separately to avoid the issue of illegal characters on windows

Yea, this is exactly what lsd2dsl does. At least on linux all the references from LSD/DSL are still correct after LSA is decoded and split into WAV files.