このページは現在英語版のみで提供されており、日本語版も近日中に提供される予定です。ご利用いただきありがとうございます。

Voice Message To Text

Feature Description

Starting from version v2.1.2, TUIKit offers a voice-to-text feature. The messaging tool in the TUIChat component supports converting voice messages into text. Currently, it can recognize Mandarin, Cantonese, English, and Japanese and convert them into corresponding text.
After voice is converted to text, the results will be retained for the duration of the current login session, and remain saved even after conversation switching.
Note:
The voice-to-text feature is currently offered for free. You can contact us through the Telegram technical exchange group to enable and experience the full feature.



Feature Introduction

Setting the Source Language for Voice-to-Text Conversion

By default, the source language for voice-to-text conversion can be automatically recognized for Mandarin, Cantonese, and English, so users do not need to manually set the source language in simple scenarios. However, to ensure the accuracy of recognition, you can also manually set the source language. Currently, the following four options are supported:
zh (cmn-Hans-CN), Standard Chinese
en-US, English
yue-Hant-HK, Cantonese
ja-JP, Japanese
The specific modification method is as follows: In the file TUIKit/components/TUIChat/utils/convertVoiceToText.ts, modify the input parameters called by the TUIChatService.convertVoiceToText method (taking Japanese as an example), and add the language attribute:
const response: IChatResponese<{ result: string }> = await TUIChatService.convertVoiceToText({
message: msg,
language: 'ja-JP', // add this new line
});

Extended Reading

The following content serves as supplementary reading material only. Voice-to-text conversion and related features have been implemented in TUIKit 2.1.1 and later, and do not require manual implementation by users.

Checking Whether the Current Package Supports the Feature

By querying the StoreName.APP in TUIStore for the key enabledVoiceToText, the obtained boolean value indicates whether the feature is enabled.
const enable = TUIStore.getData(StoreName.APP, 'enabledVoiceToText');
if (enable) {
// ...
}

Removing the Voice-to-Text Feature

In the file TUIKit/components/TUIChat/message-list/message-tool/index.vue, simply delete the object with the key convert in actionItems.
{
key: 'convert',
text: TUITranslateService.t('TUIChat.Text Conversion'),
visible: false,
iconUrl: convertText,
renderCondition() {},
clickEvent: convertVoiceToText,
}