Voice Recorder Component

image

Like that! Make sure you’re using the URL I gave you. :+1:

5 Likes

Here are my before and after results:

(Also note that the only embedded .mp3 player not showing the length of time for the clip is the one recorded on Windows, both before and after.)

BEFORE:

AFTER:

Let me know if you’d like me to do any more tests!

2 Likes

It works for me using iPad and iPhone, on DiscourseHub too. Lenght of a clip shows up when playing.

3 Likes

Thanks for the feedback, Jakke!

Also, thanks to @denvergeeks, I fixed two issues, and he confirmed that everything now plays perfectly.

I’m going to PR soon. :+1:

5 Likes

I made the PR :+1:

Possible features for other PRs:

  • Add support for chat
  • Add support for pause/resume
10 Likes

Such awesomeness

3 Likes

Here’s a crazy thought – an AI Transcription Button for uploaded .mp3 audio files in the composer? That way a user could (now) record a post in the composer, and also make it text-readable and searchable.

What would it take to include the OpenAI/Whisper capability?

Or, in the AI dropdown options which appear upon selecting the file in the composer…

…could include a Transcribe Text option

8 Likes

That would be an interesting and helpful feature! :+1:

I will check the feasibility another day.

8 Likes

Highly appreciated on this one !

3 Likes

If implemented in Chat, then inline auto-transcribing could also include translations.

5 Likes

I updated this component in the system.
https://github.com/paviliondev/discourse-voice-recorder

tried on firefox/safari/chrome on mac, and iphone
it shows this, it does not record.
could someone confirm, thanks…

image

2 Likes

Can you check the browser’s console if you see errors?

At this point, it means something is blocking the library script loading.

3 Likes

I just freshly installed the TC from the paviliondev repository as linked above.

Everything is working in my Discourse instance. Here is a video…

(And no errors appear in the console at any step of creating/uploading/playing.)

4 Likes

this is discourse 3.2.1 hosted on communiteq

load-script.js:43 Refused to load the script ‘https://www.mydiscoursesite.com/uploads/db9860/original/3X/c/f/cf579d0503105d41f84653929d510e17f12d9f5b.js’ because it violates the following Content Security Policy directive:
"script-src
https://www.mydiscoursesite.com/logs/
https://www.mydiscoursesite.com/sidekiq/
https://www.mydiscoursesite.com/mini-profiler-resources/
https://www.mydiscoursesite.com/assets/
https://www.mydiscoursesite.com/extra-locales/
https://www.mydiscoursesite.com/highlight-js/
https://www.mydiscoursesite.com/javascripts/
https://www.mydiscoursesite.com/plugins/
https://www.mydiscoursesite.com/theme-javascripts/
https://www.mydiscoursesite.com/svg-sprite/

2 Likes

I can reproduce.

A recently introduced setting allows external scripts to run dynamically without manual configuration.
It’s not available in 3.2.

image

it’s definitively not a good idea to allow the “/uploads” directory.
However, as a workaround, allowing only the URLs should be okay.

If you go to the component settings:
image

You can right-click on each link to copy and paste them to the content security policy script-src setting.

I don’t know if there is a better way to handle the CSP issue here from a theme component. :thinking:

1 Like

thanks @Arkshine

in the console, I saw these 2 js in /uploads/ url, and added to the list of “content security policy script src”

https://www.site.com/uploads/db9860/original/3X/c/f/cf579d0503105d41f84653929d510e17f12d9f5b.js
https://www.site.com/uploads/db9860/original/3X/a/2/a25eb4ec6c9652e57eefc81bc25c81105232369b.js

confirmed the browser permission for recording.
then, everytime when start a recording, it gets the error with a different url, seems the id is generated on the fly ?

https://www.site.com/8f955841-9b8b-4857-8549-ac57ee0e4517
https://www.site.com/d43014ac-e80d-4879-83a2-bd046d43a25c

adding these url does not help, seems it is generated for each recording… ?

1 Like

Can try to add script-src: blob: in content security policy script-src, too, please?

3 Likes

it works, thanks @Arkshine !

looking forward to the voice-recording in chat :slight_smile:

3 Likes

I didn’t have this error, apparently because I already had blob: as an entry in content security policy script src because @peter.be’s plugin had required it and since removing that plugin I had not removed blob: as an entry in content security policy script src, so it was already there, as below…

Is it also required to add mp3 to the authorized extensions list in the Discourse admin settings? I also have that already from before as well…

3 Likes

Just to think about: CSP has tendency break things badly, and because of that it is quite usual to use rules that are practically just wildcards — and then CSP looses its idea totally.

So?

2 Likes