# Create input to node

**URL:** https://discourse.nodered.org/t/create-input-to-node/79194
**Category:** General
**Created:** [14 June 2023 11:10 UTC](https://discourse.nodered.org/t/create-input-to-node/79194 "2023-06-14T11:10:57Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)
#### Post date: [14 June 2023 11:10 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/1 "2023-06-14T11:10:57Z")

</div>

Hello everyone!  
Could someone help me? The attached js code works on the dashboard for clicking, but I want to start it with "start"-"stop" in the payload. I already tried, but it doesn't work. I have already given it the input in the html file, so it appears on the node as input. ( inputs:1, )  
[mikrofon.txt](https://discourse.nodered.org/uploads/short-url/83Psca8iZJEiukbuQ8bP4irg7EX.txt) (17.3 KB)  
 ![mic](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/df5a840e2e4be8b269b00e25d32928746c2c4650.png)

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [16 June 2023 01:50 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/2 "2023-06-16T01:50:10Z")

</div>

Can you confirm which node you are using ?

node-red-node-ui-microphone doesn't seem to accept any msg input

node-red-contrib-mic does but its icon is different than yours 😉

---

<div class="post-metadata">

### Author: ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)
#### Post date: [16 June 2023 16:39 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/3 "2023-06-16T16:39:35Z")

</div>

Yes, node-red-node-ui-microphone, set input ok, send start-stop in payload not working

---

<div class="post-metadata">

### Author: ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)
#### Post date: [17 June 2023 14:14 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/4 "2023-06-17T14:14:14Z")

</div>

Okay, I can't get a sound out of the mic node, but not even a string. The dashboard mic node has a string output. And that would be important to me.

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [17 June 2023 15:49 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/5 "2023-06-17T15:49:00Z")

</div>

> [@azxo1](#):
>
> Yes, node-red-node-ui-microphone, set input ok, send start-stop in payload not working

As I mentioned this node doesn't accept input, are you sure its the one you are using ?

---

<div class="post-metadata">

### Author: ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)
#### Post date: [17 June 2023 16:06 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/6 "2023-06-17T16:06:30Z")

</div>

🙂 Yes sure!

.node-red/node\_modules/node-red-node-ui-microphone/ui\_microphone.html :

```auto
  <script type="text/javascript">
    RED.nodes.registerType('ui_microphone',{ // type MUST start with ui_
        category: 'dashboard',
        color: 'rgb( 90, 242, 2)', //LIME COLOR  
        defaults: {
            name: {value: ''},
            group: {type: 'ui_group', required:true},
            order: {value: 0},
            width: {
                value: 0,
                validate: function(v) {
                    var valid = true
                    var width = v||0;
                    var currentGroup = $('#node-input-group').val()|| this.group;
                    var groupNode = RED.nodes.node(currentGroup);
                    valid = !groupNode || +width <= +groupNode.width;
                    $("#node-input-size").toggleClass("input-error",!valid);
                    return valid;
                }},
            height: {value: 0},
            maxLength: { value: 5 },
            maxRecogLength: { value: 5 },
            timeslice: { value: 0 },
            press : { value: "click" },
            mode: { value: "audio" },
            interimResults: { value: false }
        },
        inputs:1, //CREATE INPUT
        outputs:1,
        icon: "font-awesome/fa-microphone",
        paletteLabel: "microphone",
        label: function() {
            return this.name||"microphone";
        },

```

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [17 June 2023 16:19 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/7 "2023-06-17T16:19:07Z")

</div>

I understand now - You have modified the code to add the input yes ?

So did you also make modifications to handle the input messages ?

---

<div class="post-metadata">

### Author: ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)
#### Post date: [17 June 2023 18:40 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/8 "2023-06-17T18:40:42Z")

</div>

Yes, it is, but the input failed to handle  
(receive start-stop payload at the input)

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [17 June 2023 23:44 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/9 "2023-06-17T23:44:15Z")

</div>

Adding the input to the HTML file is only really cosmetic.

You will also need to re-write the code in **ui\_microphone.js** to make it process any incoming payloads.

---

<div class="post-metadata">

### Author: ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)
#### Post date: [18 June 2023 07:23 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/10 "2023-06-18T07:23:18Z")

</div>

Yes, I know that, I don't know the exact js code. I don't have enough knowledge for that. I already know how the $scope.watch function is needed, but I can't insert this into the js code of the ui microphone.  
e.g:

```auto
node.on('input', function(msg) {
			node.log("Event input: " + msg.payload);
			node.msg = msg;

			switch (msg.payload) {
			case "pause":
				node.pauseRecord();
				break;
			case "resume":
				node.resumeRecord();
				break;
			case "stop":
				node.stopRecord();
				break;
			case "start":
			default:
				node.startRecord(); //YOU SHOULD CALL UI'S OWN MICROPHONE FUNCTION HERE
				break;
			}

```

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [19 June 2023 00:25 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/11 "2023-06-19T00:25:34Z")

</div>

I don't use this node so cannot help much further.  
Having skimmed some search results I suspect that there is more to it than you may think -

> [@\[Announce\] node-red-node-ui-microphone](https://discourse.nodered.org/t/announce-node-red-node-ui-microphone/23923/24):
>
> Hi Nick, just a short question: is it possible to have your ui\_microphone button started from another button, or to have the audio capture started and stoped with values such as true and false? Thanks in advance, Philipp

Depending on your use case there are quite a few topics to be found in the forum which may be of interest.

> [@Ways to control Node-RED with speech commands](https://discourse.nodered.org/t/ways-to-control-node-red-with-speech-commands/5530):
>
> Hi folks, Although I have a very large todo list, I get distracted every time I see something interesting. So this forum is a real hell for me. I hate you guys with all your brilliant ideas and cool IOT stuff lying_face Saw multiple discussions lately about voice control, so have read some basic articles about the topic. Below a list of possible solutions I found. If anybody has some other options, preferences, dislikes, or whatever 'constructive' feedback, please let me know ... Would …

> [@\[Announce\] node-red-contrib-voice2json (beta)](https://discourse.nodered.org/t/announce-node-red-contrib-voice2json-beta/29066):
>
> After many late nights by @BartButenaers and me im happy to announce the beta of our nodes to integrate voice2json into nodered: The included nodes make it possible to bootstrap a (nearly) complete voice command application with nodered and voice2json on a linux device. This is possible for [a lot of languages](http://voice2json.org/#supported-languages) as voice2json integrates them with easily downloadable profiles. Node-red-contrib-voice2json includes: wait-wake, a node to listen to a stream of raw audio buffers to detect a wake wo…

> [@\[Announce\] node-red-contrib-personal-wake-word](https://discourse.nodered.org/t/announce-node-red-contrib-personal-wake-word/39992):
>
> Hello, I’d like to introduce: [This node](https://flows.nodered.org/node/node-red-contrib-personal-wake-word) brings integration of the awesome [node-personal-wakeword module](https://github.com/mathquis/node-personal-wakeword) to nodered. This enables an easy to use key word spotter for use as a personal wake-word in diy voice projects directly in nodered: install [node-red-contrib-personal-wake-word](https://flows.nodered.org/node/node-red-contrib-personal-wake-word) (this can take a few minutes as the node needs to build some underlying libraries) connect a microphone to your machine and install a microphone node like [node-red-contrib-sox-utils](https://github.com/johanneskropf/node-red-contrib-sox-utils) record 3-10 trimmed samples of…

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [18 August 2023 00:26 UTC](https://discourse.nodered.org/t/create-input-to-node/79194/12 "2023-08-18T00:26:14Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
