From e586fa43691a9aeac4b99c65af8f0f9944982057 Mon Sep 17 00:00:00 2001 From: "flore.harle" Date: Mon, 15 Sep 2025 13:46:27 +0200 Subject: [PATCH] Audio transcription: write transcription in log from app for test. --- Linphone/core/call/CallCore.hpp | 1 + Linphone/model/CMakeLists.txt | 2 + Linphone/model/call/CallModel.cpp | 1 + Linphone/model/core/CoreModel.cpp | 6 ++ Linphone/model/core/CoreModel.hpp | 5 ++ .../transcription/TranscriptionModel.cpp | 57 +++++++++++++++++++ .../transcription/TranscriptionModel.hpp | 54 ++++++++++++++++++ external/linphone-sdk | 2 +- 8 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 Linphone/model/transcription/TranscriptionModel.cpp create mode 100644 Linphone/model/transcription/TranscriptionModel.hpp diff --git a/Linphone/core/call/CallCore.hpp b/Linphone/core/call/CallCore.hpp index 5624c6d9d..fef736312 100644 --- a/Linphone/core/call/CallCore.hpp +++ b/Linphone/core/call/CallCore.hpp @@ -346,6 +346,7 @@ private: AudioStats mAudioStats; VideoStats mVideoStats; std::shared_ptr mRemoteMagicSearchModel; + std::shared_ptr mTranscriptionModel; bool mShouldFindRemoteFriend; QSharedPointer> mRemoteMagicSearchModelConnection; diff --git a/Linphone/model/CMakeLists.txt b/Linphone/model/CMakeLists.txt index 3680900c2..55febebdf 100644 --- a/Linphone/model/CMakeLists.txt +++ b/Linphone/model/CMakeLists.txt @@ -38,6 +38,8 @@ list(APPEND _LINPHONEAPP_SOURCES model/object/VariantObject.cpp model/search/MagicSearchModel.cpp + + model/transcription/TranscriptionModel.cpp model/setting/SettingsModel.cpp model/setting/MediastreamerUtils.cpp diff --git a/Linphone/model/call/CallModel.cpp b/Linphone/model/call/CallModel.cpp index 175b61823..e62f95dc3 100644 --- a/Linphone/model/call/CallModel.cpp +++ b/Linphone/model/call/CallModel.cpp @@ -418,6 +418,7 @@ void CallModel::onStateChanged(const std::shared_ptr &call, emit remoteVideoEnabledChanged(remoteVideoDirection == linphone::MediaDirection::SendOnly || remoteVideoDirection == linphone::MediaDirection::SendRecv); updateConferenceVideoLayout(); + CoreModel::getInstance()->setTranscriptionModel(); } else if (state == linphone::Call::State::End || state == linphone::Call::State::Error) { mDurationTimer.stop(); updateCallErrorFromReason(call->getReason()); diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 06a4ea34f..7eeffd784 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -138,6 +138,12 @@ bool CoreModel::isInitialized() const { return mStarted; } +void CoreModel::setTranscriptionModel() { + auto transcription = mCore->getTranscription(); + mTranscription = Utils::makeQObject_ptr(transcription); + mTranscription->setSelf(mTranscription); +} + std::shared_ptr CoreModel::getInstance() { return gCoreModel; } diff --git a/Linphone/model/core/CoreModel.hpp b/Linphone/model/core/CoreModel.hpp index 1c07c9cc7..be76283f5 100644 --- a/Linphone/model/core/CoreModel.hpp +++ b/Linphone/model/core/CoreModel.hpp @@ -36,6 +36,7 @@ #include "model/listener/Listener.hpp" #include "model/logger/LoggerModel.hpp" #include "model/search/MagicSearchModel.hpp" +#include "model/transcription/TranscriptionModel.hpp" #include "tool/AbstractObject.hpp" // ============================================================================= @@ -71,6 +72,8 @@ public: LinphoneEnums::MagicSearchAggregation aggregation, int maxResults); + void setTranscriptionModel(); + bool mEnd = false; linphone::ConfiguringState mConfigStatus; QString mConfigMessage; @@ -96,6 +99,8 @@ private: QTimer *mIterateTimer = nullptr; QMap mOpenIdConnections; std::shared_ptr mMagicSearch; + std::shared_ptr mTranscription; + bool mStarted = false; void setPathBeforeCreation(); diff --git a/Linphone/model/transcription/TranscriptionModel.cpp b/Linphone/model/transcription/TranscriptionModel.cpp new file mode 100644 index 000000000..41602056c --- /dev/null +++ b/Linphone/model/transcription/TranscriptionModel.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "TranscriptionModel.hpp" + +#include + +#include "model/core/CoreModel.hpp" +#include "model/friend/FriendsManager.hpp" +#include "model/setting/SettingsModel.hpp" +#include "model/tool/ToolModel.hpp" +#include "tool/Utils.hpp" +#include +#include + +DEFINE_ABSTRACT_OBJECT(TranscriptionModel) + +TranscriptionModel::TranscriptionModel(const std::shared_ptr &data, QObject *parent) + : ::Listener(data, parent) { + mustBeInLinphoneThread(getClassName()); +} + +TranscriptionModel::~TranscriptionModel() { + mustBeInLinphoneThread("~" + getClassName()); +} + +void TranscriptionModel::onTranscriptionDisplay(const std::shared_ptr &transcription) { + uint32_t lastId = transcription->getLastSentenceId(); + // uint32_t id = 1; + // if (system("clear")) std::cout << "DIDNT CLEAR!" << std::endl; + // while (id <= lastId) { + // auto name = transcription->getNameById(id); + // auto sentence = transcription->getSentenceById(id); + // // std::cout << "on_transcription_display ID : " << id << " NAME : [" << name << "] " << sentence << std::endl; + // id++; + // } + auto name = transcription->getNameById(lastId); + auto sentence = transcription->getSentenceById(lastId); + lInfo() << log().arg("onTranscriptionDisplay: ID [%1] - NAME [%2]: %3").arg(lastId).arg(name).arg(sentence); +} \ No newline at end of file diff --git a/Linphone/model/transcription/TranscriptionModel.hpp b/Linphone/model/transcription/TranscriptionModel.hpp new file mode 100644 index 000000000..0a2f49482 --- /dev/null +++ b/Linphone/model/transcription/TranscriptionModel.hpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2010-2024 Belledonne Communications SARL. + * + * This file is part of linphone-desktop + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef TRANSCRIPTION_MODEL_H_ +#define TRANSCRIPTION_MODEL_H_ + +#include "model/listener/Listener.hpp" +#include "tool/AbstractObject.hpp" + +#include "tool/LinphoneEnums.hpp" +#include +#include + +class TranscriptionModel : public ::Listener, + public linphone::TranscriptionListener, + public AbstractObject { + Q_OBJECT +public: + TranscriptionModel(const std::shared_ptr &transcription, QObject *parent = nullptr); + ~TranscriptionModel(); + +signals: + +private: + DECLARE_ABSTRACT_OBJECT + + //-------------------------------------------------------------------------------- + // LINPHONE + //-------------------------------------------------------------------------------- + virtual void onTranscriptionDisplay(const std::shared_ptr &transcription) override; + std::shared_ptr mTranscription; + +signals: + // void transcriptionReceived(); +}; + +#endif diff --git a/external/linphone-sdk b/external/linphone-sdk index 4973e38b4..a577b40f3 160000 --- a/external/linphone-sdk +++ b/external/linphone-sdk @@ -1 +1 @@ -Subproject commit 4973e38b4ad639fab5d588adf9b8a60e7015b83e +Subproject commit a577b40f32b8e5c4317321159284a214d5d1c25f