Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

rbutil: Use lang-enum.txt in voicestrings.zip if present

With this change, the code that looks for the VOICE_INVALID_VOICE_FILE
and VOICE_LANG_NAME to produce standalone clips will finally work.

Change-Id: I65ec592a1d3a6c83f92efadec72657c42552b41a

+32 -5
+32 -5
utils/rbutilqt/base/voicefile.cpp
··· 64 64 m_voiceformat = info.voicefmt(); 65 65 QString version = m_versionstring.left(m_versionstring.indexOf("-")).remove("r"); 66 66 67 + QMap<int, QString> enumstrings; 67 68 // check if voicefile is present on target 68 69 QString fn = m_mountpoint + "/.rockbox/langs/voicestrings.zip"; 69 70 LOG_INFO() << "searching for zipped voicestrings at" << fn; ··· 72 73 ZipUtil z(this); 73 74 if(z.open(fn)) { 74 75 QStringList contents = z.files(); 75 - int vindex = -1, cindex = -1; 76 + int vindex = -1, cindex = -1, eindex = -1; 76 77 for(int index = 0; index < contents.size(); ++index) { 77 78 // strip any path, we don't know the structure in the zip 78 79 if(QFileInfo(contents.at(index)).baseName() == m_lang) 79 80 vindex = index; 80 81 if(QFileInfo(contents.at(index)).baseName() == "voice-corrections") 81 82 cindex = index; 82 - if (vindex != -1 && cindex != -1) 83 + if(QFileInfo(contents.at(index)).baseName() == "lang-enum") 84 + eindex = index; 85 + 86 + if (vindex != -1 && cindex != -1 && eindex != -1) 83 87 break; 84 88 } 85 89 if(cindex != -1) { ··· 98 102 corrFile = &corrfile; 99 103 } 100 104 } 105 + if(eindex != -1) { 106 + LOG_INFO() << "extracting voice corrections file"; 107 + QTemporaryFile enumfileT; 108 + enumfileT.open(); 109 + QTextStream in(&enumfileT); 110 + QString cfn = enumfileT.fileName(); 111 + if(z.extractArchive(cfn, QFileInfo(contents.at(eindex)).fileName())) { 112 + emit logItem(tr("Extracted language enumeration file from installation"), LOGINFO); 113 + 114 + while(!in.atEnd()) { 115 + QString line = in.readLine(); 116 + QStringList row = line.split(":"); 117 + int id = row[0].toInt(NULL, 0); 118 + QString name = row[1]; 119 + enumstrings[id] = name; 120 + } 121 + enumfileT.close(); 122 + } 123 + } 101 124 if(vindex != -1) { 102 125 LOG_INFO() << "extracting strings file from zip"; 103 126 // extract strings ··· 142 165 m_filename = voicefontlist.fileName(); 143 166 for(auto key : voicestrings.keys()) { 144 167 QByteArray qba; 145 - qba = QString("id: %1_%2\n") 146 - .arg(key < 0x8000 ? "LANG" : "VOICE") 147 - .arg(key).toUtf8(); 168 + if (enumstrings.contains(key)) { 169 + qba = QString("id: %1\n").arg(enumstrings[key]).toUtf8(); 170 + } else { 171 + qba = QString("id: %1_%2\n") 172 + .arg(key < 0x8000 ? "LANG" : "VOICE") 173 + .arg(key).toUtf8(); 174 + } 148 175 voicefontlist.write(qba); 149 176 qba = QString("voice: \"%1\"\n").arg( 150 177 voicestrings[key]).toUtf8();