Why the speak recognition score is 0 - azure-cognitive-services

I use cognitive speech sdk sample to create a Speaker Recognition profiler, it works fine, the result score is 0.8, then I want to reuse the profile, but the score is always 0.
Where am I wrong?
void TextIndependentVerification(shared_ptr<VoiceProfileClient> client, shared_ptr<SpeakerRecognizer> recognizer)
{
std::cout << "Text Independent Verification:\n\n";
auto profile = VoiceProfile::FromId("3b32c3dc-a974-497f-b6af-7cda3b607751");
std::cout << "Created profile ID: " << profile->GetId() << "\n";
SpeakerVerify(profile, recognizer);
}

Please follow the below REST API to verify existing profiles against input audio.
https://learn.microsoft.com/en-us/rest/api/speakerrecognition/verification/textindependent/verifyprofile
Using the SDK you can use the following helper function and to verify pass the existing voice profile.

Related

Retrieve data from QDBusMessage in Qt

I'm developing an app which have to implement a WiFi connection mechanism (it'll be a fullscreen touchscreen app). To do that I'm using the DBus to communicate with Network Manager. I managed to successfully make it scan access points and list them in the QTableView. Next thing will be to connect to the chosen wifi network. First thing I do when trying to connect is checking if there is an existing connection to that access point already in the system so I do this:
settings = new QDBusInterface("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings", "org.freedesktop.NetworkManager.Settings", dbusConnection, this);
QDBusMessage msg = settings->call("ListConnections");
QDBusArgument arg = msg.arguments().at(0).value<QDBusArgument>();
QList<QDBusObjectPath> pathsList = qdbus_cast<QList<QDBusObjectPath>>(arg);
foreach (QDBusObjectPath p, pathsList) {
QDBusInterface *conn = new QDBusInterface("org.freedesktop.NetworkManager", p.path(), "org.freedesktop.NetworkManager.Settings.Connection", dbusConnection);
QDBusMessage msg = conn->call("GetSettings");
qDebug() << "Reply: " << msg;
}
I receive the message and can read it with qDebug(). The message is in d-bus format: a{sa{sv}} as the documentation for Network Manager says. And I have problem to parse it to any usable form. From what I understand, the equivalent Qt classes I should put the data to are:
QList<QMap<QString, QMap<QString, QVariant>>>
And I think I should do it with the QDBusArgument class but can't figure out how exactly it should be done. Can someone tell me what is the best way to do this?
Thanks.
I managed to solve my problem, it turned out to be quite easy. I created the map object and used >> operator:
QDBusArgument arg = args.at(0).value<QDBusArgument>();
QMap<QString, QMap<QString, QVariant>> map;
arg >> map;

How do I download a file from google drive using v3 rest api?

My Objective: To download a sqlite file from google drive using google drive v3 rest api
I am working on project that involves downloading a sqlite file which is stored in google drive. So far I have been in successfull in authorizing and getting the access token. I also had luck getting all the file names (sqlite files) stored in the google drive with their respective file id. Now I want to download the file using the file id. I followed the documentation, and send the request with file id. But all i am getting is
{
"kind": "drive#file",
"id": "1AmaXWbtmkvihy1g9yoYSSCssgL4fVh6t",
"name": "_db.sqlite",
"mimeType": "application/octet-stream"
}
This is my code:
bool File_Control::Download_File(const QString &FileName)
{
// Get FileID
QString FileID = m_Map.value(FileName, QString());
if(FileID.isEmpty()){
emit setMessage("Fatal Error: FileID is missing for FileName");
return false;
}
qDebug()<<"File ID "<<FileID;
// Now Prepare the request
QUrl url(tr("https://www.googleapis.com/drive/v3/files/%1").arg(FileID));
QUrlQuery query;
query.addQueryItem("alt","media");
url.setQuery(query.query());
QNetworkRequest request(url);
QString headerData = "Bearer " + m_Settings->get_Google_Drive_Settings
(Google_Drive::AccessTokenEnum);
request.setRawHeader("Authorization", headerData.toLocal8Bit());
QNetworkReply *reply = m_Account->get_Request(request);
// Now wait for the response
QTime t1 = QTime::currentTime().addMSecs(TIMEOUT);
while((t1>QTime::currentTime()) && (!reply->isFinished())){
QCoreApplication::processEvents();
}
if(reply->isFinished())
{
if(reply->error() != QNetworkReply::NoError){
emit setMessage("Error: "+reply->errorString());
delete reply;
return false;
}
else{
QByteArray array = reply->readAll();
qDebug()<<array<<reply->error();
delete reply;
return true;
}
}
else{
emit setMessage("Error: Timeout");
delete reply;
return false;
}
}
Am I missing something?
Edit 1:
m_Map -> QMap that stores file names (of files from drive) as key and file id as value.
m_Settings -> A helper object that helps in getting access_token which is stored in Windows Registry
Google_Drive -> A helper enum type.
m_Account -> Object that helps in authorising google account. This object contains my QNetworkManager so i made a function called get_Request to get my "get request"
Initially I din't set the alt to media, so that explains the reponse I have got in the first place. Then I have set the value as shown in the code.
The issue was, that I was trying to see the contents of QByteArray in the debugging console. Since the array contains binary data, Qt did not show any characters and I thought that Google has sent an empty packet.
To make the matter worse, I have read this guide and tried to reproduce it in my browser. So I have got the error code 400.
Eventually, I have thought about checking the size of the array and to my surprise it was the same as the size of the original file on the drive. Then I have saved the contents of the array to a local file and checked the SQLite file and everything was OK.

QT 5.5 - QNetworkReply empty data

I already took at others questions but I didn't find an answer.
I have a problem to print HTML code I download with a QNetworkAccessManager.
I need to log into a website to retrieve this code.
I have a slot like this:
void Aims::slotRequestFinished(QNetworkReply* requestReply)
{
QString data = QString(requestReply->readAll());
qDebug() << data;
}
For the first two steps (connection), I can see the HTML code in the console.
The last step doesn't get any data. There is no redirection nor error.
Now, the stranger part is that when I change my code to show the page into a webview, qDebug doesn't show anything, but the code loaded is shown correctly in the webview.
void Aims::slotRequestFinished(QNetworkReply* requestReply)
{
QString data = QString(requestReply->readAll());
qDebug() << data;
ui->webView->setHtml(data);
}
Well, I can save the content into a file. But I would really like to understand why I can't see anything in qDebug

Retrieve all the file paths from a QDropEvent

I implemented drag and drop in my software. Basically I've got a QTableView which contains file paths. The user must be able to just drag and drop files in the QTableView in order to add them.
I've already done the big of the job but I'm stuck in iterating all the paths contained in the QDropEvent object. I have to implement the dropEvent method.
void Generous::dropEvent(QDropEvent *dropEvent) {
QStringList filePathList;
// Way to iterate dropEvent and append each file path to filePathList.
addFilesToListView(filePathList);
}
How can I do that?
I would guess that a drag and drop using filepaths use the MIME type text/uri-list.
If this is true, you should probably be able to retrieve the data like this:
if (dropEvent->mimeData()->hasUrls())
{
foreach (QUrl url, dropEvent->mimeData()->urls())
{
filePathList << url.toLocalFile();
}
}
Anyway, since I am not sure, the best would be first to check what kind of info is stored inside the drop event, and see where and how you can extract the filepaths:
QStringList availableMimeTypes = dropEvent->mimeData()->formats();
qDebug() << "available MIME types:" << dropEvent->mimeData()->formats() << "\n";
foreach(QString mimeType, availableMimeTypes)
{
qDebug() << "data for MIME type" << mimeType << " :";
qDebug() << dropEvent->mimeData()->data(mimeType) << "\n";
}
You can also create a global list that will keep appending the filePaths on each dropevent. So at the end you will be having a complete list of paths.

Screen locker in Qt

Are there any Qt based screen lockers on linux systems ?
i.e. 4 pin digit or password screen locker ?
Any reference will be greatly appreciated.
On linux, the screen locking is done by the screensavers, and the password is the one from the user linux account.
You can use QProcess to run a command line and check if it was successful:
gnome-screensaver-command --lock
xscreensaver-command --lock
qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
qdbus org.gnome.ScreenSaver /ScreenSaver Lock
xlock
And/or use QtDBus module to do the same thing
// Tries to lock the screen and returns true if successful
bool LockScreenWithDBus() {
QDBusConnection bus = QDBusConnection::sessionBus();
if(!bus.isConnected())
return false;
QStringList services;
services << "org.freedesktop.ScreenSaver"
<< "org.gnome.ScreenSaver"
// These last two are probably not necessary, because kde uses freedesktop
// conventions for dbus
<< "org.kde.ScreenSaver"
<< "org.kde.krunner";
foreach(QString service, services) {
QDBusInterface screenSaverInterface(service, "/ScreenSaver",
QString(), bus);
if (!screenSaverInterface.isValid())
continue;
QDBusReply<void> reply = screenSaverInterface.call("Lock");
if (reply.isValid())
return true;
}
return false;
}
You can create a top level FrameLess Semi transparent QWidget of Screen Height and screen width and in its center place your Textbox for password asking.

Resources