QB64 Phoenix Edition
Chuck Norris Facts! - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: QBJS, BAM, and Other BASICs (https://staging.qb64phoenix.com/forumdisplay.php?fid=50)
+--- Thread: Chuck Norris Facts! (/showthread.php?tid=1635)

Pages: 1 2


Chuck Norris Facts! - dbox - 04-21-2023

Have you ever wished you had a desktop background that would tell you random Chuck Norris facts?  Haven't we all?

Well now your wish has become a reality:
Code: (Select All)
Dim img
img = _LoadImage("https://images01.military.com/sites/default/files/styles/full/public/2021-04/chucknorris.jpeg.jpg?itok=2b4A6n29")
_PutImage , img
_Fullscreen

Do
    _Delay 2

    Dim result As Object
    result = Fetch("https://api.chucknorris.io/jokes/random")

    If result.ok Then
        Dim obj As Object
        obj = JSON.parse(result.text)
        Say obj.value   
    End If
Loop


Sub Say (text As String)
    $If Javascript Then
        var synth = window.speechSynthesis;
        if (synth) {
            var utterance = new SpeechSynthesisUtterance(text);
            synth.speak(utterance);   
            while (synth.speaking) {
                await QB.sub__Delay(.5);
            }
            success = -1;
        }
    $End If
End Sub

View in QBJS


RE: Chuck Norris Facts! - mnrvovrfc - 04-21-2023

I'm going to round-house kick this into orbit!

LOL I got a forum error trying to post this first. I'm not a spammer nor troll please stupid forum quit peaking me off. I was laughing before until this happened. I've already abandoned another forum because of this B.S.


RE: Chuck Norris Facts! - SMcNeill - 04-22-2023

I gave this a run, and there appears to be some sort of delay in the initialization of the speech.  Every quote that is read off has the first several seconds missing.  Something is off on the syncing with them, I think.


RE: Chuck Norris Facts! - dbox - 04-22-2023

(04-22-2023, 10:55 AM)SMcNeill Wrote: I gave this a run, and there appears to be some sort of delay in the initialization of the speech.  Every quote that is read off has the first several seconds missing.  Something is off on the syncing with them, I think.

Interesting, I didn’t see that in my tests.  What browser?


RE: Chuck Norris Facts! - bplus - 04-22-2023

A little delay in Opera, I thought I had to click screen to get it started. 

Maybe Chuck Norris could speed things up Smile


RE: Chuck Norris Facts! - dbox - 04-22-2023

(04-22-2023, 12:41 PM)bplus Wrote: A little delay in Opera, I thought I had to click screen to get it started. 

Maybe Chuck Norris could speed things up Smile

It takes Chuck Norris 20 minutes to watch 60 Minutes.


RE: Chuck Norris Facts! - SMcNeill - 04-23-2023

(04-22-2023, 11:04 AM)dbox Wrote:
(04-22-2023, 10:55 AM)SMcNeill Wrote: I gave this a run, and there appears to be some sort of delay in the initialization of the speech.  Every quote that is read off has the first several seconds missing.  Something is off on the syncing with them, I think.

Interesting, I didn’t see that in my tests.  What browser?

Opera, on the iPad.
Vivaldi on the PC.

Both tend to have the same delay of a few seconds upon playing for me.

Edit: Just tried with Edge on the PC and there's no delay with it, that I can tell. Things tend to start and play without being cut of any with it, letting you hear the whole quote.


RE: Chuck Norris Facts! - aurel - 04-23-2023

I  can confirm that open Chuck in Edge without any delay
but for example not work in SeaMonkey
...ahh stupid browsers


RE: Chuck Norris Facts! - CharlieJV - 04-23-2023

(04-22-2023, 11:04 AM)dbox Wrote:
(04-22-2023, 10:55 AM)SMcNeill Wrote: I gave this a run, and there appears to be some sort of delay in the initialization of the speech.  Every quote that is read off has the first several seconds missing.  Something is off on the syncing with them, I think.

Interesting, I didn’t see that in my tests.  What browser?

Sounds like there's going to be some digging involved.  If of any help:

 https://www.google.com/search?q=SpeechSynthesis+api+delay&rlz=1CATRYO_enCA1021CA1021&sxsrf=APwXEdfQzbfq67ioOp-PqXQ28_XAW-W3ow%3A1682272519837&ei=B3FFZOTPMuKaptQPmPGIiAI&ved=0ahUKEwik79a_ycD-AhVijYkEHZg4AiEQ4dUDCBA&uact=5&oq=SpeechSynthesis+api+delay&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIFCCEQoAE6CggAEEcQ1gQQsAM6CggAEIoFELADEEM6BwgAEIoFEEM6BQgAEIAEOgoIABCABBAUEIcCOgYIABAWEB46CggAEBYQHhAPEAo6CwgAEBYQHhAPEPEEOggIABAWEB4QDzoICAAQigUQhgNKBAhBGABQ6ghYvRhgpyZoAXABeACAAY4BiAGkCZIBBDAuMTCYAQCgAQHIAQrAAQE&sclient=gws-wiz-serp#ip=1

The beauty of programming with web browsers as the target: a program will work out-of-the-box on so many devices.

The problem: when using any web api's (any newer browser-engine/javascript stuff), not all browsers on all devices are at the same milestone of development/support/compatibility, occasionally because some software/device "houses" don't want to play ball/nice.  AND: testing a browser-based app for all browsers on all devices, that's a tough thing to do.


RE: Chuck Norris Facts! - dbox - 04-23-2023

Thanks for the feedback everyone!  Besides being an excuse to have Chuck Norris in a post (which was the main point), this was really just an extension of the QBJS Fun Fact #4 from the other thread that was demonstrating how you can extend the native functionality of QBJS by calling out directly to Javascript code.  This is meant to be analogous to making calls out to C libraries in QB64 or shelling out to external executables or executing assembly in QBasic to extend beyond the native functionality of QB64.  It is certainly not representative of a typical QBJS program.

So, this particular example didn't get a lot of rigorous cross-browser testing, because, again, it's just a silly Chuck Norris joke.

However, I do make an effort to test the core functionality of QBJS and the QBJS IDE in as many browsers as is feasible.  I focus on the following browsers which represent greater than 90% of the total market utilization:  Chrome, Safari, Edge, and Firefox.  I simply don't have the bandwidth to test in the more obscure browsers.  It would be analogous to trying to test QB64 for every linux distribution out there.

Lots of fun new stuff in the works for the next release that I hope to share soon!