fix:parser and ui
Android / build-android (push) Successful in 2m30s

This commit is contained in:
intelligence committed 2026-08-29 15:43:35 +02:00
1 parent 2b89bbd959
commit 066c7d758e
23 files changed
+867 -29

No files matched your search

+2 -12
View File
@@ -15,6 +15,8 @@
#include <utility>
#include <vector>
#include "transcript_cleaner.h"
namespace {
constexpr const char* kAppId = "io.github.transui";
@@ -333,18 +335,6 @@ size_t curl_write(char* buffer, size_t size, size_t nmemb, void* data) {
return size * nmemb;
}
std::string clean_transcript(std::string transcript) {
// Qwen3-ASR prefixes transcripts with the detected language and this marker.
constexpr const char* kLanguagePrefix = "language ";
constexpr const char* kTextMarker = "<astext>";
if (transcript.compare(0, std::strlen(kLanguagePrefix), kLanguagePrefix) != 0) {
return transcript;
}
const size_t marker = transcript.find(kTextMarker, std::strlen(kLanguagePrefix));
if (marker == std::string::npos) return transcript;
return transcript.substr(marker + std::strlen(kTextMarker));
}
bool transcription_request(const std::string& url, const std::string& key,
const std::string& model, const std::string& path,
const std::string& prompt,
+33
View File
@@ -0,0 +1,33 @@
#include "transcript_cleaner.h"
#include <cctype>
#include <string_view>
std::string clean_transcript(std::string transcript) {
// Qwen3-ASR prefixes raw transcripts with the detected language and a text marker.
constexpr std::string_view kLanguagePrefix = "language ";
constexpr std::string_view kMarkers[] = {"<asr_text>", "<astext>"};
size_t prefix = 0;
if (transcript.compare(0, 3, "\xef\xbb\xbf") == 0) prefix = 3;
while (prefix < transcript.size() &&
std::isspace(static_cast<unsigned char>(transcript[prefix]))) {
prefix++;
}
if (transcript.compare(prefix, kLanguagePrefix.size(), kLanguagePrefix) != 0) {
return transcript;
}
size_t marker_position = std::string::npos;
std::string_view matched_marker;
for (std::string_view marker : kMarkers) {
const size_t position = transcript.find(marker, prefix + kLanguagePrefix.size());
if (position != std::string::npos &&
(marker_position == std::string::npos || position < marker_position)) {
marker_position = position;
matched_marker = marker;
}
}
if (marker_position == std::string::npos) return transcript;
return transcript.substr(marker_position + matched_marker.size());
}
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include <string>
std::string clean_transcript(std::string transcript);