File indexing completed on 2022-11-22 14:07:13

0001 /*
0002     SPDX-FileCopyrightText: 2021 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003 
0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include "ui_speechdialog_ui.h"
0010 #include "timeline2/model/timelineitemmodel.hpp"
0011 #include "definitions.h"
0012 #include "pythoninterfaces/speechtotext.h"
0013 
0014 
0015 #include <QProcess>
0016 #include <QTemporaryFile>
0017 
0018 class QAction;
0019 
0020 /**
0021  * @class SpeechDialog
0022  * @brief A dialog for editing markers and guides.
0023  * @author Jean-Baptiste Mardelle
0024  */
0025 class SpeechDialog : public QDialog, public Ui::SpeechDialog_UI
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     explicit SpeechDialog(std::shared_ptr<TimelineItemModel> timeline, QPoint zone, int tid, bool activeTrackOnly = false, bool selectionOnly = false,
0031                           QWidget *parent = nullptr);
0032     ~SpeechDialog() override;
0033 
0034 private:
0035     std::unique_ptr<QProcess> m_speechJob;
0036     const std::shared_ptr<TimelineItemModel> m_timeline;
0037     QPoint m_zone;
0038     int m_tid;
0039     int m_duration;
0040     std::unique_ptr<QTemporaryFile> m_tmpAudio;
0041     std::unique_ptr<QTemporaryFile> m_tmpSrt;
0042     QMetaObject::Connection m_modelsConnection;
0043     QAction *m_voskConfig;
0044     SpeechToText *m_stt;
0045 
0046 private slots:
0047     void slotProcessSpeech();
0048     void slotProcessSpeechStatus(QProcess::ExitStatus status, const QString &srtFile);
0049     void slotProcessProgress();
0050 };