@innovastudio/contentbuilder 1.4.82 → 1.4.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.82",
4
+ "version": "1.4.84",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -77395,7 +77395,7 @@ class Lib {
77395
77395
  }
77396
77396
 
77397
77397
  // import RecordRTC from 'recordrtc';
77398
-
77398
+ // import Recorder from 'opus-recorder'; // Using Recorder
77399
77399
  const dom = new Dom();
77400
77400
  class Dictation {
77401
77401
  constructor(opts = {}, builder) {
@@ -77829,11 +77829,17 @@ class Dictation {
77829
77829
  // track.stop();
77830
77830
  // });
77831
77831
 
77832
- // Using mediaRecorder
77833
- if (this.mediaRecorder && this.mediaRecorder.state !== 'inactive') {
77834
- this.mediaRecorder.stop();
77835
- this.localStream.getTracks().forEach(track => track.stop()); // Stop the tracks to release the resources
77836
- }
77832
+ if (this.builder.useMediaRecorder) {
77833
+ // Using mediaRecorder
77834
+ if (this.mediaRecorder && this.mediaRecorder.state !== 'inactive') {
77835
+ this.mediaRecorder.stop();
77836
+ this.localStream.getTracks().forEach(track => track.stop()); // Stop the tracks to release the resources
77837
+ }
77838
+ } /* else {
77839
+ // Using Recorder
77840
+ if(this.recorder) this.recorder.stop();
77841
+ if(this.localStream) this.localStream.getTracks().forEach(track => track.stop()); // Stop the tracks to release the resources
77842
+ } */
77837
77843
 
77838
77844
  if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
77839
77845
  this.websocket.close();
@@ -77882,30 +77888,47 @@ class Dictation {
77882
77888
  return;
77883
77889
  }
77884
77890
  const sampleRate = 16000;
77891
+ if (this.builder.useMediaRecorder) {
77892
+ // Using mediaRecorder
77893
+ navigator.mediaDevices.getUserMedia({
77894
+ audio: {
77895
+ sampleSize: 16,
77896
+ channelCount: 1,
77897
+ sampleRate: sampleRate
77898
+ }
77899
+ }).then(stream => {
77900
+ this.localStream = stream;
77901
+ this.mediaRecorder = new MediaRecorder(stream);
77902
+ this.mediaRecorder.addEventListener('dataavailable', event => {
77903
+ if (this.aborted) return;
77904
+
77905
+ // console.log(event.data);
77906
+ // if (event.data.size > 0) {
77907
+ // }
77908
+ this.websocket.send(event.data);
77909
+ });
77885
77910
 
77886
- // Using mediaRecorder
77887
- navigator.mediaDevices.getUserMedia({
77888
- audio: {
77889
- sampleSize: 16,
77890
- channelCount: 1,
77891
- sampleRate: sampleRate
77892
- }
77893
- }).then(stream => {
77894
- this.localStream = stream;
77895
- this.mediaRecorder = new MediaRecorder(stream);
77896
- this.mediaRecorder.addEventListener('dataavailable', event => {
77897
- if (this.aborted) return;
77898
-
77899
- // console.log(event.data);
77900
- // if (event.data.size > 0) {
77901
- // }
77902
- this.websocket.send(event.data);
77911
+ // this.mediaRecorder.start(1000);
77912
+ }).catch(error => {
77913
+ console.log(error);
77903
77914
  });
77904
-
77905
- // this.mediaRecorder.start(1000);
77906
- }).catch(error => {
77907
- console.log(error);
77908
- });
77915
+ } /* else {
77916
+ // Using Recorder
77917
+ this.recorder = new Recorder({
77918
+ encoderPath: this.builder.encoderPath||
77919
+ 'https://cdnjs.cloudflare.com/ajax/libs/opus-recorder/8.0.5/encoderWorker.min.js',
77920
+ leaveStreamOpen: true,
77921
+ numberOfChannels: 1,
77922
+ // OPUS options
77923
+ encoderSampleRate: sampleRate,
77924
+ streamPages: true,
77925
+ maxBuffersPerPage: 1,
77926
+ });
77927
+ this.recorder.ondataavailable = (e) => {
77928
+ if(this.aborted) return;
77929
+ this.websocket.send(e.buffer);
77930
+ };
77931
+ } */
77909
77932
 
77910
77933
  /*
77911
77934
  // Using RecordRTC
@@ -77934,25 +77957,32 @@ class Dictation {
77934
77957
  }, 2000);
77935
77958
  }
77936
77959
  let finalTranscripts = '';
77960
+ let speechTimeout;
77937
77961
  this.websocket.onmessage = event => {
77938
77962
  const message = JSON.parse(event.data);
77939
77963
  if (message.event === 'can-open-mic') {
77940
77964
  //this.recorder.startRecording(); // Using RecordRTC
77941
77965
 
77942
- this.mediaRecorder.start(1000); // Using mediaRecorder
77966
+ if (this.builder.useMediaRecorder) {
77967
+ this.mediaRecorder.start(1000); // Using mediaRecorder
77968
+ } /* else {
77969
+ this.recorder.start(); // Using Recorder
77970
+ } */
77943
77971
 
77944
77972
  // console.log('Start Dictation');
77945
77973
  this.aborted = false;
77946
77974
  }
77947
77975
  if (message.event === 'transcript-result') {
77948
- const transcripts = message.data;
77949
77976
  if (this.builder.isInProgress || this.aborted) {
77950
77977
  return;
77951
77978
  }
77952
- finalTranscripts += ' ' + transcripts;
77979
+ const transcript = message.data.channel.alternatives[0].transcript;
77980
+ if (transcript && message.data.is_final) {
77981
+ finalTranscripts += ' ' + transcript;
77982
+ }
77953
77983
  inpCommand.value = finalTranscripts;
77954
- clearTimeout(this.speechTimeout);
77955
- this.speechTimeout = setTimeout(() => {
77984
+ clearTimeout(speechTimeout);
77985
+ speechTimeout = setTimeout(() => {
77956
77986
  this.builder.commandText = '';
77957
77987
  finalTranscripts = '';
77958
77988
  if (this.builder.autoSendCommand) {
@@ -78773,7 +78803,7 @@ class ContentBuilder {
78773
78803
  enableDragResize: true,
78774
78804
  simpleTextSettings: false,
78775
78805
  enableColumnsPerLine: true,
78776
- /* Prompt/Command Stuff */
78806
+ /* Prompt/Command Stuff for AI Assistant */
78777
78807
  isContentBox: false,
78778
78808
  sendCommandUrl: 'http://localhost:8081/answer',
78779
78809
  // speechTranscribeUrl: 'http://192.168.1.7:8081',
@@ -78782,6 +78812,9 @@ class ContentBuilder {
78782
78812
  commandPlaceholderText: '',
78783
78813
  enableShortCommands: true,
78784
78814
  speechRecognitionLang: 'en-US',
78815
+ useMediaRecorder: true,
78816
+ // do not change
78817
+ encoderPath: '',
78785
78818
  headlineList: ['We create simple and effective designs.', 'Ultimate Experiences With Story, Emotion, And Purpose.', 'Build Anything Beautifully', 'With Less Stuff and More Compassion', 'We\'re [CompanyName]. Full stack development with a spark of creativity.', 'Transforming your digital experience with [CompanyName]. Achieve your online goals with our customized solutions.', 'Revolutionizing web development with [CompanyName]. Unleash your digital potential with our high-performance solutions.', 'Creative and Inspiring'],
78786
78819
  shortCommandList: {
78787
78820
  undo: ['undo'],