Commit 8672cec1 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Speech to text: attempt to fix Windows UTF-8 encoding, fix crash when no clip...

Speech to text: attempt to fix Windows UTF-8 encoding, fix crash when no clip selected and incorrect subtitle tooltip
parent edcf8d3e
Pipeline #50673 passed with stage
in 10 minutes and 42 seconds
......@@ -8,7 +8,7 @@ import sys
import os
import wave
import subprocess
import json
import codecs
import datetime
SetLogLevel(-1)
......@@ -40,10 +40,12 @@ def transcribe():
while True:
data = process.stdout.read(4000)
if len(data) == 0:
print(rec.FinalResult(), file = sys.stdout, flush=True)
sys.stdout.buffer.write(rec.FinalResult().encode('utf-8'))
sys.stdout.flush()
break
if rec.AcceptWaveform(data):
print (rec.Result(), file = sys.stdout, flush=True)
sys.stdout.buffer.write(rec.Result().encode('utf-8'))
sys.stdout.flush()
transcribe()
#with open(sys.argv[3], 'w') as f:
......
......@@ -227,6 +227,15 @@ void TextBasedEdit::startRecognition()
info_message->animatedShow();
return;
}
const QString cid = pCore->getMonitor(Kdenlive::ClipMonitor)->activeClipId();
std::shared_ptr<AbstractProjectItem> clip = pCore->projectItemModel()->getItemByBinId(cid);
if (clip == nullptr) {
info_message->setMessageType(KMessageWidget::Information);
info_message->setText(i18n("Select a clip in Project Bin."));
info_message->animatedShow();
return;
}
m_speechJob.reset(new QProcess(this));
info_message->setMessageType(KMessageWidget::Information);
info_message->setText(i18n("Starting speech recognition"));
......@@ -239,8 +248,6 @@ void TextBasedEdit::startRecognition()
m_sourceUrl.clear();
QString clipName;
const QString cid = pCore->getMonitor(Kdenlive::ClipMonitor)->activeClipId();
std::shared_ptr<AbstractProjectItem> clip = pCore->projectItemModel()->getItemByBinId(cid);
m_offset = 0;
m_lastPosition = 0;
double endPos = 0;
......@@ -333,7 +340,6 @@ void TextBasedEdit::slotProcessSpeechError()
void TextBasedEdit::slotProcessSpeech()
{
QString saveData = QString::fromUtf8(m_speechJob->readAllStandardOutput());
//saveData.replace(QStringLiteral("\\\""), QStringLiteral("\""));
qDebug()<<"=== GOT DATA:\n"<<saveData;
QJsonParseError error;
auto loadDoc = QJsonDocument::fromJson(saveData.toUtf8(), &error);
......
......@@ -837,7 +837,7 @@ Rectangle {
height: root.collapsedHeight
onClicked: timeline.triggerAction('audio_recognition')
ToolTip {
visible: muteButton.hovered
visible: analyseButton.hovered
font: miniFont
delay: 1500
timeout: 5000
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment