mirror of
https://github.com/RavenX8/companion-module-voicemod.git
synced 2026-04-03 12:58:52 -04:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
0e6d8f9c8b
|
|||
| 735fc3d2ae | |||
| d5ce9d1810 | |||
| 56d486e4cf | |||
| 73e4f56599 | |||
| 095ab387c6 | |||
| b9df465090 | |||
| 619e10d43f |
@@ -1,3 +1,6 @@
|
||||
# companion-module-voicemod
|
||||
|
||||
A [BitFocus Companion](https://bitfocus.io/companion/) module for interacting
|
||||
with [Voicemod](https://www.voicemod.net/)'s control api.
|
||||
|
||||
See [HELP.md](./companion/HELP.md) and [LICENSE](./LICENSE)
|
||||
|
||||
28
actions.js
28
actions.js
@@ -62,5 +62,33 @@ module.exports = function (self) {
|
||||
self.vm.stopAllSounds()
|
||||
},
|
||||
},
|
||||
hear_self: {
|
||||
name: 'Toggle Hear Self',
|
||||
options: [],
|
||||
callback: async (event) => {
|
||||
self.vm.internal.toggleHearMyVoice()
|
||||
},
|
||||
},
|
||||
hear_background: {
|
||||
name: 'Toggle Hear Background',
|
||||
options: [],
|
||||
callback: async (event) => {
|
||||
self.vm.internal.toggleBackground()
|
||||
},
|
||||
},
|
||||
mute_mic: {
|
||||
name: 'Toggle Mute Mic',
|
||||
options: [],
|
||||
callback: async (event) => {
|
||||
self.vm.internal.toggleMuteMic()
|
||||
},
|
||||
},
|
||||
mute_memes_for_me: {
|
||||
name: 'Toggle Mute Soundboard for me',
|
||||
options: [],
|
||||
callback: async (event) => {
|
||||
self.vm.internal.toggleMuteMemeForMe()
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
## Your module
|
||||
## Voicemod API
|
||||
|
||||
Write some help for your users here!
|
||||
### Configuration
|
||||
|
||||
Due to a limitation in the voicemod software, host address should always be 127.0.0.1.
|
||||
It was stated in their issue tracker that they will be looking at adding a toggle to
|
||||
allow connections from outside the local host.
|
||||
|
||||
This would benefit users that want to run voicemod on another system from the controlling software.
|
||||
|
||||
20
feedbacks.js
20
feedbacks.js
@@ -3,9 +3,9 @@ const { combineRgb } = require('@companion-module/base')
|
||||
module.exports = async function (self) {
|
||||
self.setFeedbackDefinitions({
|
||||
VoiceChangerState: {
|
||||
name: 'Voice Changer State',
|
||||
name: 'Voice Changer Enabled',
|
||||
type: 'boolean',
|
||||
label: 'Voice Changer State',
|
||||
label: 'Voice Changer Enabled',
|
||||
defaultStyle: {
|
||||
bgcolor: combineRgb(255, 0, 0),
|
||||
color: combineRgb(0, 0, 0),
|
||||
@@ -16,9 +16,9 @@ module.exports = async function (self) {
|
||||
},
|
||||
},
|
||||
BackgroundEffectState: {
|
||||
name: 'Background Effect State',
|
||||
name: 'Background Effect Enabled',
|
||||
type: 'boolean',
|
||||
label: 'Background Effect Status',
|
||||
label: 'Background Effect Enabled',
|
||||
defaultStyle: {
|
||||
bgcolor: combineRgb(255, 0, 0),
|
||||
color: combineRgb(0, 0, 0),
|
||||
@@ -29,9 +29,9 @@ module.exports = async function (self) {
|
||||
},
|
||||
},
|
||||
HearMyVoiceState: {
|
||||
name: 'Hear My Voice State',
|
||||
name: 'Hear My Voice Enabled',
|
||||
type: 'boolean',
|
||||
label: 'Hear My Voice State',
|
||||
label: 'Hear My Voice Enabled',
|
||||
defaultStyle: {
|
||||
bgcolor: combineRgb(255, 0, 0),
|
||||
color: combineRgb(0, 0, 0),
|
||||
@@ -42,9 +42,9 @@ module.exports = async function (self) {
|
||||
},
|
||||
},
|
||||
MicMutedState: {
|
||||
name: 'Microphone Mute State',
|
||||
name: 'Microphone Mute Enabled',
|
||||
type: 'boolean',
|
||||
label: 'Microphone Mute State',
|
||||
label: 'Microphone Mute Enabled',
|
||||
defaultStyle: {
|
||||
bgcolor: combineRgb(255, 0, 0),
|
||||
color: combineRgb(0, 0, 0),
|
||||
@@ -55,9 +55,9 @@ module.exports = async function (self) {
|
||||
},
|
||||
},
|
||||
MemesMutedForMeState: {
|
||||
name: 'Soundboard - Mute For Me State',
|
||||
name: 'Soundboard - Mute For Me Enabled',
|
||||
type: 'boolean',
|
||||
label: 'Soundboard Mute For Me State',
|
||||
label: 'Soundboard Mute For Me Enabled',
|
||||
defaultStyle: {
|
||||
bgcolor: combineRgb(255, 0, 0),
|
||||
color: combineRgb(0, 0, 0),
|
||||
|
||||
61
main.js
61
main.js
@@ -3,6 +3,7 @@ const UpgradeScripts = require('./upgrades')
|
||||
const UpdateActions = require('./actions')
|
||||
const UpdateFeedbacks = require('./feedbacks')
|
||||
const UpdateVariableDefinitions = require('./variables')
|
||||
const UpdatePresets = require('./presets')
|
||||
const { VoiceMod } = require('voicemod')
|
||||
|
||||
class ModuleInstance extends InstanceBase {
|
||||
@@ -19,6 +20,7 @@ class ModuleInstance extends InstanceBase {
|
||||
this.hearMyVoiceEnabled = false
|
||||
this.muteEnabled = false
|
||||
this.muteMemesEnabled = false
|
||||
this.currentVoiceName = ''
|
||||
}
|
||||
|
||||
sleep(ms) {
|
||||
@@ -33,57 +35,90 @@ class ModuleInstance extends InstanceBase {
|
||||
this.updateStatus(InstanceStatus.Connecting)
|
||||
this.vm = new VoiceMod(this.config.host, this.config.apiKey === '' ? 'anyClient' : this.config.apiKey)
|
||||
try {
|
||||
this.vm.init().then(
|
||||
await this.vm.init().then(
|
||||
async () => {
|
||||
this.vm.internal.on('backgroundEffectsEnabledEvent', (background) => {
|
||||
this.backgroundEffectsEnabled = true
|
||||
this.checkFeedbacks('BackgroundEffectState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('backgroundEffectsDisabledEvent', (background) => {
|
||||
this.backgroundEffectsEnabled = false
|
||||
this.checkFeedbacks('BackgroundEffectState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('voiceChangerEnabledEvent', (data) => {
|
||||
this.voiceChangerEnabled = true
|
||||
this.checkFeedbacks('VoiceChangerState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('voiceChangerDisabledEvent', (data) => {
|
||||
this.voiceChangerEnabled = false
|
||||
this.checkFeedbacks('VoiceChangerState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('hearMySelfEnabledEvent', (data) => {
|
||||
this.hearMyVoiceEnabled = true
|
||||
this.checkFeedbacks('HearMyVoiceState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('hearMySelfDisabledEvent', (data) => {
|
||||
this.hearMyVoiceEnabled = false
|
||||
this.checkFeedbacks('HearMyVoiceState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('muteMicrophoneEnabledEvent', (data) => {
|
||||
this.muteEnabled = true
|
||||
this.checkFeedbacks('MicMutedState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('muteMicrophoneDisabledEvent', (data) => {
|
||||
this.muteEnabled = false
|
||||
this.checkFeedbacks('MicMutedState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('muteMemeForMeEnabledEvent', (data) => {
|
||||
this.muteMemesEnabled = true
|
||||
this.checkFeedbacks('MemesMutedForMeState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('muteMemeForMeDisabledEvent', (data) => {
|
||||
this.muteMemesEnabled = false
|
||||
this.checkFeedbacks('MemesMutedForMeState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('getAllSoundboard', (data) => {
|
||||
this.updateActions()
|
||||
})
|
||||
this.vm.internal.on('voiceLoadedEvent', (data) => {
|
||||
this.currentVoiceName = data.voiceId
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('getCurrentVoice', (data) => {
|
||||
this.currentVoiceName = data.voiceId
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('toggleVoiceChanger', (data) => {
|
||||
this.voiceChangerEnabled = data.value
|
||||
this.checkFeedbacks('VoiceChangerState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.on('toggleMuteMic', (data) => {
|
||||
this.muteEnabled = data.value
|
||||
this.checkFeedbacks('MicMutedState')
|
||||
this.updateVariableDefinitions()
|
||||
})
|
||||
this.vm.internal.getVoiceChangerStatus()
|
||||
this.vm.internal.getBackgroundEffectStatus()
|
||||
this.vm.internal.getMuteMicStatus()
|
||||
this.vm.internal.getMuteMemeForMeStatus()
|
||||
|
||||
await this.vm.internal.getCurrentVoice()
|
||||
this.vm.internal.getVoiceChangerStatus()
|
||||
this.vm.internal.getMuteMicStatus()
|
||||
|
||||
this.failure = 0
|
||||
this.loaded = true
|
||||
this.updateStatus(InstanceStatus.Ok)
|
||||
this.updatePresets()
|
||||
this.updateActionsFeedbacksVariables()
|
||||
|
||||
this.loaded = true
|
||||
this.log('debug', 'connected to VM and ready')
|
||||
},
|
||||
(reason) => {
|
||||
@@ -97,7 +132,6 @@ class ModuleInstance extends InstanceBase {
|
||||
this.updateStatus(InstanceStatus.UnknownError)
|
||||
++this.failure
|
||||
}
|
||||
if (this.loaded === false) await this.sleep(500)
|
||||
} while (this.loaded === false && this.failure < 5)
|
||||
}
|
||||
// When module gets deleted
|
||||
@@ -124,7 +158,7 @@ class ModuleInstance extends InstanceBase {
|
||||
id: 'apiKey',
|
||||
type: 'textinput',
|
||||
label: 'API Key',
|
||||
tooltip: 'Enter your developer API Key for voicemod (not required for now)',
|
||||
tooltip: 'Enter your API Key for voicemod (https://control-api.voicemod.net)',
|
||||
default: '',
|
||||
},
|
||||
]
|
||||
@@ -153,10 +187,17 @@ class ModuleInstance extends InstanceBase {
|
||||
|
||||
this.setVariableValues({
|
||||
microphoneMuted: this.muteEnabled,
|
||||
voiceChangerStatus: !this.voiceChangerEnabled,
|
||||
voiceSelected: undefined,
|
||||
hearMyVoice: this.hearMyVoiceEnabled,
|
||||
hearBackgroundMusic: this.backgroundEffectsEnabled,
|
||||
hearMemesForMe: this.muteMemesEnabled,
|
||||
voiceChangerStatus: this.voiceChangerEnabled,
|
||||
voiceSelected: this.currentVoiceName,
|
||||
})
|
||||
}
|
||||
|
||||
updatePresets() {
|
||||
UpdatePresets(this)
|
||||
}
|
||||
}
|
||||
|
||||
runEntrypoint(ModuleInstance, UpgradeScripts)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "voicemod-api",
|
||||
"version": "0.2.0",
|
||||
"version": "1.0.0",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"format": "prettier -w ."
|
||||
@@ -12,7 +12,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@companion-module/base": "~1.5.1",
|
||||
"voicemod": "git+https://github.com/RavenX8/voicemod-api.git#companion-module-voicemod-api"
|
||||
"voicemod": "git+https://github.com/RavenX8/voicemod-api.git#39a07b74e20e76d0ff5776f0768d1c934364a9fd"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@companion-module/tools": "^1.4.1"
|
||||
|
||||
39
presets.js
Normal file
39
presets.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const { combineRgb } = require('@companion-module/base')
|
||||
|
||||
module.exports = async function (self) {
|
||||
const presets = {}
|
||||
presets[`beep`] = {
|
||||
type: 'button',
|
||||
category: 'Sounds',
|
||||
name: 'Beep!',
|
||||
style: {
|
||||
text: `Beep!`,
|
||||
size: '24',
|
||||
color: combineRgb(255, 255, 255),
|
||||
bgcolor: combineRgb(0, 0, 0),
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
down: [
|
||||
{
|
||||
actionId: 'set_beep_sound',
|
||||
options: {
|
||||
beepEnabled: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
up: [
|
||||
{
|
||||
actionId: 'set_beep_sound',
|
||||
options: {
|
||||
beepEnabled: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
feedbacks: [],
|
||||
}
|
||||
|
||||
self.setPresetDefinitions(presets)
|
||||
}
|
||||
@@ -3,5 +3,8 @@ module.exports = async function (self) {
|
||||
{ variableId: 'microphoneMuted', name: 'Microphone Muted' },
|
||||
{ variableId: 'voiceChangerStatus', name: 'Voice Changer Enabled' },
|
||||
{ variableId: 'voiceSelected', name: 'Current Voice Selected' },
|
||||
{ variableId: 'hearMyVoice', name: 'Hear My Voice Enabled' },
|
||||
{ variableId: 'hearBackgroundMusic', name: 'Background Music Enabled' },
|
||||
{ variableId: 'hearMemesForMe', name: 'Hear Memes for Me Enabled' },
|
||||
])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user