@5minds/node-red-dashboard-2-processcube-audio-capture 0.1.5 → 0.1.6-feature-28bcca-m7omvn63

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.
@@ -0,0 +1,156 @@
1
+ [
2
+ {
3
+ "id": "3cb65f6178d62207",
4
+ "type": "tab",
5
+ "label": "Flow 1",
6
+ "disabled": false,
7
+ "info": "",
8
+ "env": []
9
+ },
10
+ {
11
+ "id": "8652d6c4dad0776b",
12
+ "type": "ui-base",
13
+ "name": "My Dashboard",
14
+ "path": "/dashboard",
15
+ "includeClientData": true,
16
+ "acceptsClientConfig": ["ui-notification", "ui-control"],
17
+ "showPathInSidebar": false,
18
+ "navigationStyle": "fixed",
19
+ "titleBarStyle": "default"
20
+ },
21
+ {
22
+ "id": "54b46b6ceee9fa4b",
23
+ "type": "ui-theme",
24
+ "name": "Default Theme",
25
+ "colors": {
26
+ "surface": "#ffffff",
27
+ "primary": "#0094CE",
28
+ "bgPage": "#eeeeee",
29
+ "groupBg": "#ffffff",
30
+ "groupOutline": "#cccccc"
31
+ },
32
+ "sizes": {
33
+ "density": "default",
34
+ "pagePadding": "12px",
35
+ "groupGap": "12px",
36
+ "groupBorderRadius": "4px",
37
+ "widgetGap": "12px"
38
+ }
39
+ },
40
+ {
41
+ "id": "eaf3f6b08faae2f2",
42
+ "type": "ui-page",
43
+ "name": "Page 1",
44
+ "ui": "8652d6c4dad0776b",
45
+ "path": "/page1",
46
+ "icon": "home",
47
+ "layout": "grid",
48
+ "theme": "54b46b6ceee9fa4b",
49
+ "breakpoints": [
50
+ {
51
+ "name": "Default",
52
+ "px": "0",
53
+ "cols": "3"
54
+ },
55
+ {
56
+ "name": "Tablet",
57
+ "px": "576",
58
+ "cols": "6"
59
+ },
60
+ {
61
+ "name": "Small Desktop",
62
+ "px": "768",
63
+ "cols": "9"
64
+ },
65
+ {
66
+ "name": "Desktop",
67
+ "px": "1024",
68
+ "cols": "12"
69
+ }
70
+ ],
71
+ "order": 1,
72
+ "className": "",
73
+ "visible": "true",
74
+ "disabled": "false"
75
+ },
76
+ {
77
+ "id": "ccfab3cb61427e32",
78
+ "type": "ui-group",
79
+ "name": "Group 1",
80
+ "page": "eaf3f6b08faae2f2",
81
+ "width": "12",
82
+ "height": "1",
83
+ "order": 1,
84
+ "showTitle": true,
85
+ "className": "",
86
+ "visible": "true",
87
+ "disabled": "false",
88
+ "groupType": "default"
89
+ },
90
+ {
91
+ "id": "a629f5e941dca64d",
92
+ "type": "Service Host",
93
+ "apiBase": "https://api.openai.com/v1",
94
+ "secureApiKeyHeaderOrQueryName": "Authorization",
95
+ "organizationId": "",
96
+ "name": ""
97
+ },
98
+ {
99
+ "id": "f7073522f3360aad",
100
+ "type": "OpenAI API",
101
+ "z": "3cb65f6178d62207",
102
+ "name": "",
103
+ "property": "payload",
104
+ "propertyType": "msg",
105
+ "service": "a629f5e941dca64d",
106
+ "method": "createTranscription",
107
+ "x": 630,
108
+ "y": 380,
109
+ "wires": [["4fc15fcca7c916ac"]]
110
+ },
111
+ {
112
+ "id": "4fc15fcca7c916ac",
113
+ "type": "debug",
114
+ "z": "3cb65f6178d62207",
115
+ "name": "debug 2",
116
+ "active": true,
117
+ "tosidebar": true,
118
+ "console": false,
119
+ "tostatus": false,
120
+ "complete": "false",
121
+ "statusVal": "",
122
+ "statusType": "auto",
123
+ "x": 840,
124
+ "y": 380,
125
+ "wires": []
126
+ },
127
+ {
128
+ "id": "c0dc71cf8cf07db5",
129
+ "type": "function",
130
+ "z": "3cb65f6178d62207",
131
+ "name": "function 1",
132
+ "func": "msg.payload = {\n file: msg.payload.filePath,\n model:'whisper-1',\n language:'de',\n prompt: \"Bitte transkribiere die folgende Audioaufnahme und formuliere den Text professionell und prägnant. Der Text soll gut strukturiert sein, einen formellen Ton haben und für geschäftliche oder akademische Zwecke geeignet sein. Achte darauf, die ursprüngliche Bedeutung und den Kontext beizubehalten, aber Ausdrucksweisen zu optimieren, um die Klarheit und Lesbarkeit zu verbessern.\"\n}\nreturn msg;",
133
+ "outputs": 1,
134
+ "timeout": 0,
135
+ "noerr": 0,
136
+ "initialize": "",
137
+ "finalize": "",
138
+ "libs": [],
139
+ "x": 420,
140
+ "y": 380,
141
+ "wires": [["f7073522f3360aad"]]
142
+ },
143
+ {
144
+ "id": "8880d0386e3cb1ef",
145
+ "type": "ui-audio-capture",
146
+ "z": "3cb65f6178d62207",
147
+ "name": "",
148
+ "group": "ccfab3cb61427e32",
149
+ "start": "Aufnehmen...",
150
+ "stop": "Stop",
151
+ "send": "Aufnahme senden",
152
+ "x": 250,
153
+ "y": 380,
154
+ "wires": [["c0dc71cf8cf07db5"]]
155
+ }
156
+ ]
@@ -9,10 +9,30 @@ module.exports = function (RED) {
9
9
 
10
10
  const group = RED.nodes.getNode(config.group);
11
11
 
12
+ function addConnectionCredentials(RED, msg, conn) {
13
+ if (!msg._client) {
14
+ msg._client = {};
15
+ }
16
+ RED.plugins.getByType('node-red-dashboard-2').forEach((plugin) => {
17
+ if (plugin.hooks?.onAddConnectionCredentials && msg) {
18
+ msg = plugin.hooks.onAddConnectionCredentials(conn, msg);
19
+ }
20
+ });
21
+ msg._client = {
22
+ ...msg._client,
23
+ ...{
24
+ socketId: conn.id,
25
+ socketIp: conn.handshake?.address,
26
+ },
27
+ };
28
+
29
+ return msg;
30
+ }
31
+
12
32
  const evts = {
13
33
  onSocket: {
14
34
  'handle-audio': async function (conn, id, audioData) {
15
- const msg = {};
35
+ let msg = {};
16
36
  msg.payload = audioData;
17
37
 
18
38
  const audioBlob = Buffer.from(audioData.fileBase64, 'base64');
@@ -26,6 +46,7 @@ module.exports = function (RED) {
26
46
  } else {
27
47
  node.log(`Audio file saved to: ${tempFile.name}`);
28
48
  msg.payload.filePath = tempFile.name;
49
+ msg = addConnectionCredentials(RED, msg, conn);
29
50
  node.send(msg);
30
51
  }
31
52
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-dashboard-2-processcube-audio-capture",
3
- "version": "0.1.5",
3
+ "version": "0.1.6-feature-28bcca-m7omvn63",
4
4
  "description": "A node to capture audio and pass the audio data on in the flow",
5
5
  "keywords": [
6
6
  "node-red",
@@ -30,7 +30,8 @@
30
30
  "dist/*",
31
31
  "nodes/*",
32
32
  "ui/*",
33
- "resources/*"
33
+ "resources/*",
34
+ "examples/*"
34
35
  ],
35
36
  "scripts": {
36
37
  "build": "vite build",
@@ -68,4 +69,4 @@
68
69
  }
69
70
  }
70
71
  }
71
- }
72
+ }
@@ -1,2 +1,2 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("button[data-v-eb9ab7bf]{padding:8px;border-style:solid;border-radius:4px}.ui-audio-capture[data-v-eb9ab7bf]{display:flex;flex-direction:column;align-items:center;gap:10px;width:100%;padding:5px}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
2
- (function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s["ui-audio-capture"]={},s.Vue))})(this,function(s,t){"use strict";const c=(i,e)=>{const r=i.__vccOpts||i;for(const[n,d]of e)r[n]=d;return r},u={name:"AudioCapture",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!1,visible:!1})}},data(){return{isRecording:!1,mediaRecorder:null,audioCanBeSend:!1,audioChunks:[]}},computed:{start(){return this.props.start||"Start"},stop(){return this.props.stop||"Stop"},send(){return this.props.send||"Send"}},methods:{async toggleRecording(){this.isRecording?this.stopRecording():await this.startRecording()},async startRecording(){this.audioCanBeSend=!1;try{const i=await navigator.mediaDevices.getUserMedia({audio:!0});this.mediaRecorder=new MediaRecorder(i),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.audioChunks.push(e.data)},this.mediaRecorder.start(),this.isRecording=!0}catch(i){console.error("Error accessing microphone:",i)}},stopRecording(){this.audioCanBeSend=!0,this.mediaRecorder&&this.mediaRecorder.state!=="inactive"&&(this.mediaRecorder.stop(),this.mediaRecorder=null,this.isRecording=!1)},sendAudio(){this.audioCanBeSend=!1;const i=new Blob(this.audioChunks,{type:"audio/webm"}),e=new FileReader;e.onloadend=()=>{const r=e.result.split(",")[1];this.$socket.emit("handle-audio",this.id,{fileBase64:r,fileBlob:i,fileChunks:this.audioChunks}),this.audioChunks=[]},e.readAsDataURL(i)}}},l={class:"ui-audio-capture"};function p(i,e,r,n,d,o){return t.openBlock(),t.createElementBlock("div",l,[t.createElementVNode("button",{onClick:e[0]||(e[0]=(...a)=>o.toggleRecording&&o.toggleRecording(...a))},t.toDisplayString(d.isRecording?o.stop:o.start),1),d.audioCanBeSend?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:e[1]||(e[1]=(...a)=>o.sendAudio&&o.sendAudio(...a))},t.toDisplayString(o.send),1)):t.createCommentVNode("",!0)])}const h=c(u,[["render",p],["__scopeId","data-v-eb9ab7bf"]]);s.AudioCapture=h,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("button[data-v-8fc5f90a]{padding:8px;border-style:solid;border-radius:4px}.ui-audio-capture[data-v-8fc5f90a]{display:flex;flex-direction:column;align-items:center;gap:10px;width:100%;padding:5px}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
2
+ (function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s["ui-audio-capture"]={},s.Vue))})(this,function(s,t){"use strict";const c=(i,e)=>{const r=i.__vccOpts||i;for(const[n,d]of e)r[n]=d;return r},u={name:"AudioCapture",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!1,visible:!1})}},data(){return{isRecording:!1,mediaRecorder:null,audioCanBeSend:!1,audioChunks:[]}},computed:{start(){return this.props.start||"Start"},stop(){return this.props.stop||"Stop"},send(){return this.props.send||"Send"}},methods:{async toggleRecording(){this.isRecording?this.stopRecording():await this.startRecording()},async startRecording(){this.audioCanBeSend=!1;try{const i=await navigator.mediaDevices.getUserMedia({audio:!0});this.mediaRecorder=new MediaRecorder(i),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.audioChunks.push(e.data)},this.mediaRecorder.start(),this.isRecording=!0}catch(i){console.error("Error accessing microphone:",i)}},stopRecording(){this.audioCanBeSend=!0,this.mediaRecorder&&this.mediaRecorder.state!=="inactive"&&(this.mediaRecorder.stop(),this.mediaRecorder=null,this.isRecording=!1)},sendAudio(){this.audioCanBeSend=!1;const i=new Blob(this.audioChunks,{type:"audio/webm"}),e=new FileReader;e.onloadend=()=>{const r=e.result.split(",")[1];this.$socket.emit("handle-audio",this.id,{fileBase64:r,fileBlob:i,fileChunks:this.audioChunks}),this.audioChunks=[]},e.readAsDataURL(i)}}},l={class:"ui-audio-capture"};function p(i,e,r,n,d,o){return t.openBlock(),t.createElementBlock("div",l,[t.createElementVNode("button",{onClick:e[0]||(e[0]=(...a)=>o.toggleRecording&&o.toggleRecording(...a))},t.toDisplayString(d.isRecording?o.stop:o.start),1),d.audioCanBeSend?(t.openBlock(),t.createElementBlock("button",{key:0,onClick:e[1]||(e[1]=(...a)=>o.sendAudio&&o.sendAudio(...a))},t.toDisplayString(o.send),1)):t.createCommentVNode("",!0)])}const h=c(u,[["render",p],["__scopeId","data-v-8fc5f90a"]]);s.AudioCapture=h,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
@@ -75,10 +75,12 @@ export default {
75
75
  reader.onloadend = () => {
76
76
  const base64data = reader.result.split(',')[1];
77
77
  this.$socket.emit('handle-audio', this.id, {
78
+
78
79
  fileBase64: base64data,
79
80
  fileBlob: audioBlob,
80
81
  fileChunks: this.audioChunks,
81
82
  });
83
+
82
84
  this.audioChunks = [];
83
85
  };
84
86
  reader.readAsDataURL(audioBlob);
@@ -89,4 +91,4 @@ export default {
89
91
 
90
92
  <style scoped>
91
93
  @import '../stylesheets/ui-audio-capture.css';
92
- </style>
94
+ </style>