Audio transcription: write transcription in log from app for test.

This commit is contained in:
flore.harle 2025-09-15 13:46:27 +02:00
parent bad52def4d
commit e586fa4369
8 changed files with 127 additions and 1 deletions

View file

@ -346,6 +346,7 @@ private:
AudioStats mAudioStats;
VideoStats mVideoStats;
std::shared_ptr<MagicSearchModel> mRemoteMagicSearchModel;
std::shared_ptr<TranscriptionModel> mTranscriptionModel;
bool mShouldFindRemoteFriend;
QSharedPointer<SafeConnection<CallCore, MagicSearchModel>> mRemoteMagicSearchModelConnection;

View file

@ -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

View file

@ -418,6 +418,7 @@ void CallModel::onStateChanged(const std::shared_ptr<linphone::Call> &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());

View file

@ -138,6 +138,12 @@ bool CoreModel::isInitialized() const {
return mStarted;
}
void CoreModel::setTranscriptionModel() {
auto transcription = mCore->getTranscription();
mTranscription = Utils::makeQObject_ptr<TranscriptionModel>(transcription);
mTranscription->setSelf(mTranscription);
}
std::shared_ptr<CoreModel> CoreModel::getInstance() {
return gCoreModel;
}

View file

@ -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<QString, OIDCModel *> mOpenIdConnections;
std::shared_ptr<MagicSearchModel> mMagicSearch;
std::shared_ptr<TranscriptionModel> mTranscription;
bool mStarted = false;
void setPathBeforeCreation();

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "TranscriptionModel.hpp"
#include <QDebug>
#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 <functional>
#include <iostream>
DEFINE_ABSTRACT_OBJECT(TranscriptionModel)
TranscriptionModel::TranscriptionModel(const std::shared_ptr<linphone::Transcription> &data, QObject *parent)
: ::Listener<linphone::Transcription, linphone::TranscriptionListener>(data, parent) {
mustBeInLinphoneThread(getClassName());
}
TranscriptionModel::~TranscriptionModel() {
mustBeInLinphoneThread("~" + getClassName());
}
void TranscriptionModel::onTranscriptionDisplay(const std::shared_ptr<linphone::Transcription> &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);
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TRANSCRIPTION_MODEL_H_
#define TRANSCRIPTION_MODEL_H_
#include "model/listener/Listener.hpp"
#include "tool/AbstractObject.hpp"
#include "tool/LinphoneEnums.hpp"
#include <QObject>
#include <linphone++/linphone.hh>
class TranscriptionModel : public ::Listener<linphone::Transcription, linphone::TranscriptionListener>,
public linphone::TranscriptionListener,
public AbstractObject {
Q_OBJECT
public:
TranscriptionModel(const std::shared_ptr<linphone::Transcription> &transcription, QObject *parent = nullptr);
~TranscriptionModel();
signals:
private:
DECLARE_ABSTRACT_OBJECT
//--------------------------------------------------------------------------------
// LINPHONE
//--------------------------------------------------------------------------------
virtual void onTranscriptionDisplay(const std::shared_ptr<linphone::Transcription> &transcription) override;
std::shared_ptr<linphone::Transcription> mTranscription;
signals:
// void transcriptionReceived();
};
#endif

@ -1 +1 @@
Subproject commit 4973e38b4ad639fab5d588adf9b8a60e7015b83e
Subproject commit a577b40f32b8e5c4317321159284a214d5d1c25f