Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Cannot use WebRTC AudioCapture with WebEngineView connected to local server via WebKitSpeechRecognition

Cannot use WebRTC AudioCapture with WebEngineView connected to local server via WebKitSpeechRecognition

Scheduled Pinned Locked Moved Unsolved Qt WebKit
qtwebengineviewqmlwebengineqtquickqt 5.15.0
1 Posts 1 Posters 654 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nodelogic
    wrote on last edited by
    #1

    Hello. I am having trouble getting a WebEngineView to convert speech to text using the SpeechRecognition API.
    if I access the same page from chrome, the URL is able to correctly recognize speech, but in the Qt Web Engine View, it doesn't even appear to be accessing the microphone.

    This is on Qt 5.15.0 on Kubuntu (lastest). Other Qt components are able to detect and use the microphone, however the WebEngineView cannot. No errors are returned and under closer inspection of the Qt 5.15.0 source code, it seems to be setting the feature to -1 by default with Q_UNREACHABLE() before it.. not sure what this implies or if its relevant but..

    (From Qt 5.15 Source)
    5.15.0/Src/qtwebengine/src/webengine/api/qquickwebengineview.cpp

    static QQuickWebEngineView::Feature toFeature(QtWebEngineCore::ProfileAdapter::PermissionType type)
    {
        switch (type) {
        case QtWebEngineCore::ProfileAdapter::NotificationPermission:
            return QQuickWebEngineView::Notifications;
        case QtWebEngineCore::ProfileAdapter::GeolocationPermission:
            return QQuickWebEngineView::Geolocation;
        default:
            break;
        }
        Q_UNREACHABLE();
        return QQuickWebEngineView::Feature(-1);
    }
    
    
    void QQuickWebEngineViewPrivate::runFeaturePermissionRequest(QtWebEngineCore::ProfileAdapter::PermissionType permission, const QUrl &url)
    {
        Q_Q(QQuickWebEngineView);
        Q_EMIT q->featurePermissionRequested(url, toFeature(permission));
    }
    

    main.cpp

    import QtQuick 2.15
    import QtQuick.Window 2.15
    
    import QtWebEngine 1.10
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        WebEngineView {
            id: view
            anchors.fill: parent
            url: "http://127.0.0.1/audio.html"
            audioMuted: false
            onLoadingChanged: {
                if (!view.loading) {
                    console.log("Requesting audio capture")
                   // featurePermissionRequested(url, WebEngineView.MediaAudioCapture)
                    view.grantFeaturePermission(url,
                                                WebEngineView.MediaAudioCapture,
                                                true)
                }
            }
            onFeaturePermissionRequested: {
                view.grantFeaturePermission(securityOrigin, feature, true)
            }
    
            Component.onCompleted: {
    
            }
        }
    }
    

    audio.html

    ...
    window.rc = new webkitSpeechRecognition()
    
    window.rc.onresult = function(result) { 
    ...
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved