Feat: clean model name.
This commit is contained in:
1 parent
789c8d4762
commit
00a4c9c25a
1 file changed
+13
-1
+13
-1
@@ -333,6 +333,18 @@ size_t curl_write(char* buffer, size_t size, size_t nmemb, void* data) {
|
|||||||
return size * nmemb;
|
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,
|
bool transcription_request(const std::string& url, const std::string& key,
|
||||||
const std::string& model, const std::string& path,
|
const std::string& model, const std::string& path,
|
||||||
const std::string& prompt,
|
const std::string& prompt,
|
||||||
@@ -402,7 +414,7 @@ bool transcription_request(const std::string& url, const std::string& key,
|
|||||||
g_object_unref(parser);
|
g_object_unref(parser);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*transcript = json_object_get_string_member(object, "text");
|
*transcript = clean_transcript(json_object_get_string_member(object, "text"));
|
||||||
g_object_unref(parser);
|
g_object_unref(parser);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user