tdlight/td/telegram/TranscriptionInfo.h

63 lines
1.8 KiB
C
Raw Normal View History

2022-10-19 19:43:30 +02:00
//
2022-12-31 22:28:08 +01:00
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
2022-10-19 19:43:30 +02:00
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
2023-09-21 18:11:17 +02:00
#include "td/telegram/MessageFullId.h"
2022-10-19 19:43:30 +02:00
#include "td/telegram/td_api.h"
2022-11-02 17:51:41 +01:00
#include "td/telegram/telegram_api.h"
2022-10-19 19:43:30 +02:00
#include "td/utils/common.h"
#include "td/utils/Promise.h"
#include "td/utils/Status.h"
2022-11-02 17:51:41 +01:00
#include <functional>
2022-10-19 19:43:30 +02:00
namespace td {
class Td;
2022-10-19 19:43:30 +02:00
class TranscriptionInfo {
bool is_transcribed_ = false;
int64 transcription_id_ = 0;
string text_;
// temporary state
Status last_transcription_error_;
vector<Promise<Unit>> speech_recognition_queries_;
public:
bool is_transcribed() const {
return is_transcribed_;
}
bool recognize_speech(
2023-09-21 18:11:17 +02:00
Td *td, MessageFullId message_full_id, Promise<Unit> &&promise,
2023-11-23 12:12:27 +01:00
std::function<void(Result<telegram_api::object_ptr<telegram_api::messages_transcribedAudio>>)> &&handler);
2022-10-19 19:43:30 +02:00
vector<Promise<Unit>> on_final_transcription(string &&text, int64 transcription_id);
bool on_partial_transcription(string &&text, int64 transcription_id);
vector<Promise<Unit>> on_failed_transcription(Status &&error);
2023-09-21 18:11:17 +02:00
void rate_speech_recognition(Td *td, MessageFullId message_full_id, bool is_good, Promise<Unit> &&promise) const;
2022-10-19 19:43:30 +02:00
static unique_ptr<TranscriptionInfo> copy_if_transcribed(const unique_ptr<TranscriptionInfo> &info);
static bool update_from(unique_ptr<TranscriptionInfo> &old_info, unique_ptr<TranscriptionInfo> &&new_info);
td_api::object_ptr<td_api::SpeechRecognitionResult> get_speech_recognition_result_object() const;
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
} // namespace td