Add voiceNote.recognized_text
This commit is contained in:
parent
e1cf18f1cc
commit
44832189e3
@ -311,9 +311,11 @@ video duration:int32 width:int32 height:int32 file_name:string mime_type:string
|
|||||||
//@thumbnail Video thumbnail in JPEG format; as defined by the sender; may be null @video File containing the video
|
//@thumbnail Video thumbnail in JPEG format; as defined by the sender; may be null @video File containing the video
|
||||||
videoNote duration:int32 length:int32 minithumbnail:minithumbnail thumbnail:thumbnail video:file = VideoNote;
|
videoNote duration:int32 length:int32 minithumbnail:minithumbnail thumbnail:thumbnail video:file = VideoNote;
|
||||||
|
|
||||||
//@description Describes a voice note. The voice note must be encoded with the Opus codec, and stored inside an OGG container. Voice notes can have only a single audio channel @duration Duration of the voice note, in seconds; as defined by the sender
|
//@description Describes a voice note. The voice note must be encoded with the Opus codec, and stored inside an OGG container. Voice notes can have only a single audio channel
|
||||||
//@waveform A waveform representation of the voice note in 5-bit format @mime_type MIME type of the file; as defined by the sender @voice File containing the voice note
|
//@duration Duration of the voice note, in seconds; as defined by the sender @waveform A waveform representation of the voice note in 5-bit format
|
||||||
voiceNote duration:int32 waveform:bytes mime_type:string voice:file = VoiceNote;
|
//@mime_type MIME type of the file; as defined by the sender @is_recognized True, if speech recognition is completed; Premium users only
|
||||||
|
//@recognized_text Recognized text of the voice note; Premium users only. Call recognizeSpeech to get recognized text of the voice note @voice File containing the voice note
|
||||||
|
voiceNote duration:int32 waveform:bytes mime_type:string is_recognized:Bool recognized_text:string voice:file = VoiceNote;
|
||||||
|
|
||||||
//@description Describes an animated representation of an emoji
|
//@description Describes an animated representation of an emoji
|
||||||
//@sticker Animated sticker for the emoji
|
//@sticker Animated sticker for the emoji
|
||||||
|
@ -1246,7 +1246,8 @@ tl_object_ptr<td_api::video> copy(const td_api::video &obj) {
|
|||||||
|
|
||||||
template <>
|
template <>
|
||||||
tl_object_ptr<td_api::voiceNote> copy(const td_api::voiceNote &obj) {
|
tl_object_ptr<td_api::voiceNote> copy(const td_api::voiceNote &obj) {
|
||||||
return td_api::make_object<td_api::voiceNote>(obj.duration_, obj.waveform_, obj.mime_type_, copy(obj.voice_));
|
return td_api::make_object<td_api::voiceNote>(obj.duration_, obj.waveform_, obj.mime_type_, obj.is_recognized_,
|
||||||
|
obj.recognized_text_, copy(obj.voice_));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -52,6 +52,7 @@ enum class Version : int32 {
|
|||||||
AddAudioFlags,
|
AddAudioFlags,
|
||||||
UseServerForwardAsCopy,
|
UseServerForwardAsCopy,
|
||||||
AddMainDialogListPosition,
|
AddMainDialogListPosition,
|
||||||
|
AddVoiceNoteFlags,
|
||||||
Next
|
Next
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ tl_object_ptr<td_api::voiceNote> VoiceNotesManager::get_voice_note_object(FileId
|
|||||||
auto voice_note = it->second.get();
|
auto voice_note = it->second.get();
|
||||||
CHECK(voice_note != nullptr);
|
CHECK(voice_note != nullptr);
|
||||||
return make_tl_object<td_api::voiceNote>(voice_note->duration, voice_note->waveform, voice_note->mime_type,
|
return make_tl_object<td_api::voiceNote>(voice_note->duration, voice_note->waveform, voice_note->mime_type,
|
||||||
|
voice_note->is_transcribed, voice_note->text,
|
||||||
td_->file_manager_->get_file_object(file_id));
|
td_->file_manager_->get_file_object(file_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "td/telegram/SecretInputMedia.h"
|
#include "td/telegram/SecretInputMedia.h"
|
||||||
#include "td/telegram/td_api.h"
|
#include "td/telegram/td_api.h"
|
||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
|
#include "td/telegram/Version.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/FlatHashMap.h"
|
#include "td/utils/FlatHashMap.h"
|
||||||
@ -50,7 +51,10 @@ class VoiceNotesManager {
|
|||||||
public:
|
public:
|
||||||
string mime_type;
|
string mime_type;
|
||||||
int32 duration = 0;
|
int32 duration = 0;
|
||||||
|
bool is_transcribed = false;
|
||||||
string waveform;
|
string waveform;
|
||||||
|
int64 transcription_id = 0;
|
||||||
|
string text;
|
||||||
|
|
||||||
FileId file_id;
|
FileId file_id;
|
||||||
};
|
};
|
||||||
|
@ -20,18 +20,63 @@ void VoiceNotesManager::store_voice_note(FileId file_id, StorerT &storer) const
|
|||||||
auto it = voice_notes_.find(file_id);
|
auto it = voice_notes_.find(file_id);
|
||||||
CHECK(it != voice_notes_.end());
|
CHECK(it != voice_notes_.end());
|
||||||
const VoiceNote *voice_note = it->second.get();
|
const VoiceNote *voice_note = it->second.get();
|
||||||
store(voice_note->mime_type, storer);
|
bool has_mime_type = !voice_note->mime_type.empty();
|
||||||
store(voice_note->duration, storer);
|
bool has_duration = voice_note->duration != 0;
|
||||||
store(voice_note->waveform, storer);
|
bool has_waveform = !voice_note->waveform.empty();
|
||||||
|
BEGIN_STORE_FLAGS();
|
||||||
|
STORE_FLAG(has_mime_type);
|
||||||
|
STORE_FLAG(has_duration);
|
||||||
|
STORE_FLAG(has_waveform);
|
||||||
|
STORE_FLAG(voice_note->is_transcribed);
|
||||||
|
END_STORE_FLAGS();
|
||||||
|
if (has_mime_type) {
|
||||||
|
store(voice_note->mime_type, storer);
|
||||||
|
}
|
||||||
|
if (has_duration) {
|
||||||
|
store(voice_note->duration, storer);
|
||||||
|
}
|
||||||
|
if (has_waveform) {
|
||||||
|
store(voice_note->waveform, storer);
|
||||||
|
}
|
||||||
|
if (voice_note->is_transcribed) {
|
||||||
|
store(voice_note->transcription_id, storer);
|
||||||
|
store(voice_note->text, storer);
|
||||||
|
}
|
||||||
store(file_id, storer);
|
store(file_id, storer);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
FileId VoiceNotesManager::parse_voice_note(ParserT &parser) {
|
FileId VoiceNotesManager::parse_voice_note(ParserT &parser) {
|
||||||
auto voice_note = make_unique<VoiceNote>();
|
auto voice_note = make_unique<VoiceNote>();
|
||||||
parse(voice_note->mime_type, parser);
|
bool has_mime_type;
|
||||||
parse(voice_note->duration, parser);
|
bool has_duration;
|
||||||
parse(voice_note->waveform, parser);
|
bool has_waveform;
|
||||||
|
if (parser.version() >= static_cast<int32>(Version::AddVoiceNoteFlags)) {
|
||||||
|
BEGIN_PARSE_FLAGS();
|
||||||
|
PARSE_FLAG(has_mime_type);
|
||||||
|
PARSE_FLAG(has_duration);
|
||||||
|
PARSE_FLAG(has_waveform);
|
||||||
|
PARSE_FLAG(voice_note->is_transcribed);
|
||||||
|
END_PARSE_FLAGS();
|
||||||
|
} else {
|
||||||
|
has_mime_type = true;
|
||||||
|
has_duration = true;
|
||||||
|
has_waveform = true;
|
||||||
|
voice_note->is_transcribed = false;
|
||||||
|
}
|
||||||
|
if (has_mime_type) {
|
||||||
|
parse(voice_note->mime_type, parser);
|
||||||
|
}
|
||||||
|
if (has_duration) {
|
||||||
|
parse(voice_note->duration, parser);
|
||||||
|
}
|
||||||
|
if (has_waveform) {
|
||||||
|
parse(voice_note->waveform, parser);
|
||||||
|
}
|
||||||
|
if (voice_note->is_transcribed) {
|
||||||
|
parse(voice_note->transcription_id, parser);
|
||||||
|
parse(voice_note->text, parser);
|
||||||
|
}
|
||||||
parse(voice_note->file_id, parser);
|
parse(voice_note->file_id, parser);
|
||||||
if (parser.get_error() != nullptr || !voice_note->file_id.is_valid()) {
|
if (parser.get_error() != nullptr || !voice_note->file_id.is_valid()) {
|
||||||
return FileId();
|
return FileId();
|
||||||
|
Loading…
Reference in New Issue
Block a user