Git Product home page Git Product logo

talkbot's Introduction

alt text

Talkbot

Discord bot for text-to-speech and language translation

Try it out here: https://discord.gg/NxrPp8g

Docker

  1. If your on windows10, Install wsl2 https://docs.microsoft.com/en-us/windows/wsl/install-win10 else go to step two ;)
  2. Install docker https://docs.docker.com/get-docker/
  3. Clone this repo or Download the talkbot files and extract them.
  4. Copy config/auth.example to config/auth.json and put in your discord app key.
    • To learn how to setup a discord app and get this token go here
    • AMAZON: To learn how to setup Amazon AWS Polly go here
    • AZURE: To learn how to setup Azure go here
  5. Add a file, config/google-auth.json with the google credentials
    • GOOGLE: To learn how to setup your Google API credentials go here
  6. In the command line run docker pull faxwang/talkbot:latest this will take a while.
  7. In the command line run change directory to the project root and run
    • docker-compose up -d to run talkbot in the background
    • docker-compose up to run talkbot in the foreground
  8. It should be running now.

Quick start

  1. Click here to add the bot to your discord: https://discordapp.com/oauth2/authorize?&client_id=428866923267358721&scope=bot&permissions=0
  2. Join a voice channel
  3. Type !follow
  4. Type the message Hello World to hear it read out to you

Documentation

Check out the documentation on gitbook: https://nullabork.gitbook.io/talkbot/

Commands in discord

The bot requires a master to control it. Once you're its master it'll convert your text into voice in the current voice channel. The bot will also follow you between voice channels. Other users will only be able to use the bot if you permit them to use it. If you don't use the bot for 30 minutes it'll unfollow you.

= Control =
 !follow            :: The bot will join your voice channel and speak what you write
 !unfollow          :: Release the bot
 !sidle             :: Take control of the bot from someone else
 !transfer          :: Transfer control of the bot to another person
 !permit [<user>]   :: Permit someone else to use the bot whilst it's following you
 !unpermit [<user>] :: Unpermit someone else from using the bot
 !tts               :: Speak when you're muted

= Personalization =
 !defaults              :: Reset your default voice settings
 !mypitch <pitch>       :: Alter the pitch of the bot's voice. Valid values are -20 to 20
 !myspeed <speed>       :: Alter the speed the bot talks. 1.0 is the default. Valid values are 0.25 to 4.0
 !myvoice <voice|alias> :: Change accent or style.
 !tolang <lang>         :: Translate your text to a different language eg. en, fr, jp, de etc.
 !mute                  :: Mute yourself so your text is not read out
 !unmute                :: Unmute yourself so all your text is read out

= More =
 !help info   :: info help commands
 !help server :: server help commands

Setup your own bot

Use this to setup your own bot on your own server. Note you will require a Google Cloud account to use their TTS API and an Amazon Polly account to use Amazon TTS voices. Both of these services have free tiers but may cost you money if you exceed their free caps. Each of these services can be turned on and off in the configuration of the bot.

Win 10 Software requirements

  • node js - v18
  • git

Install, setup and run

  1. Clone this respository
    • git clone https://github.com/nullabork/talkbot talkbot
    • `git
  2. Duplicate the auth.example file in the config directory and rename the new file to auth.json edit the file and paste in your discord app key.
    • To learn how to setup a discord app and get this token go here
  3. Setup your prefered API provider - Google, Amazon AWS Polly or Azure or any combination of those.
    • GOOGLE: To learn how to setup your Google API credentials go here
    • AMAZON: To learn how to setup Amazon AWS Polly go here
    • AZURE: To learn how to setup Azure go here
  4. Install NPM dependencies
    npm install
  5. Run the bot!
    • node bot.js

Updating to the latest code

To update to the latest code run: git pull

Troubleshooting

Talk to us on discord

Google TTS API Issues

Confirm you've put the path to your API credentials file in the env var GOOGLE_APPLICATION_CREDENTIALS. See Google cloud docs here

Acknowledgements

  • WootoSmash - coder/bugmaker/shitposter
  • FaxWang - coder/bugfinder/shitposter
  • GreenLionVoltronPilot - bugfinder/shitposter
  • Kingk22 - bugfinder/shitposter/questionanswerer
  • Kelinmiriel - bugfinder/shitposter
  • All the npm package builders!

Want to shitpost also?

talkbot's People

Contributors

dependabot[bot] avatar v2catch avatar wootosmash avatar zenril avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

talkbot's Issues

Bing Translate Support

I think it would be nice to be able to easily switch to bing for translations as they have a more reliable service than most others.

!sfx is broken

Setting up a sound effect no longer works when the emoji is typed in

Add role based !permit

Alter the !permit command to allow us to do a role based commit.

For example !permit @everyone would permit every person within that role.

Plaintext for textrule adding is broken

Describe the bug
Plaintext for textrule adding is broken

To Reproduce

  1. !textrule add ... -> sometext
  2. Type "write ... something"
  3. It'll only read out a few letters

Expected behavior
It should read out "Write sometext something"

Screenshots
N/A

Additional context
N/A

segmentation fault

Describe the bug
sometimes the bot just closes with an error in console 'zsh: segmentation fault node bot'

To Reproduce
Steps to reproduce the behavior:

  1. Enter channel
  2. Run the command !follow
  3. write something like ' a? b? c? d? e? f? g? h? i? j? k? l? m? n? o? p? q? r? s? t? u? v? w? x? y? z? 9? 8? 7? 6? 5? 4? 3? 2? 1? 0? -1? -2? -3? -4? -5? -6? -7? -8? -9? -? '
  4. Bot closes

Expected behavior
Bot should be useable

Additional context
running bot on macOS without docker

Azure doesn't work with implicit lang/gender settings

If you set the provider to Azure but don't explicitly choose a voice it fails to work correctly. Amazon voices were disabled.


= Voice Settings For Wokker =
voice_provider :: azure
My Voice :: default
alias :: Alice
My Lang :: de-AT
gender :: FEMALE

Deploy betabot

Deploy

  • Import server rules
  • All wootos static fixes
  • New command Format sfx textrule Import
  • personal mute/unmute
  • !t - talk command even when muted

Rolling Presence timeout is broken

Rolling Presence timeout is broken I'm seeing beta talk bot change really quickly sometimes. it's like there is two timers running. It could be lag, but it's not working as desired.

Feature: better help display format

Is your feature request related to a problem? Please describe.
Feature: better help display

Describe the solution you'd like
Display the help as a markdown metadata unfurl

Describe alternatives you've considered
The current solution uses code blocks.

Additional context
image

Azure voices stop working after a while

On beta bot, switch to an azure voice and use it for a while. It'll eventually stop playing sound without the bot failing.

Rebooting the bot fixes the issue.

Switching to another voice fixes the issue

Integrate with twitch chat

Allow the text chat from twitch to be piped through the bot into the active voice channel

Sample commands:
!twitch link
!twitch permit [subs/mods/all/username]
!twitch unpermit [subs/mods/all/username]
!twitch unlink

The word 'find' breaks it

==> forever.log <==
ERROR: { Error: 13 INTERNAL: Internal error.
at Object.exports.createStatusError (/root/discord/talkbot/node_modules/grpc/src/common.js:87:15)
at Object.onReceiveStatus (/root/discord/talkbot/node_modules/grpc/src/client_interceptors.js:1188:28)
at InterceptingListener._callNext (/root/discord/talkbot/node_modules/grpc/src/client_interceptors.js:564:42)
at InterceptingListener.onReceiveStatus (/root/discord/talkbot/node_modules/grpc/src/client_interceptors.js:614:8)
at callback (/root/discord/talkbot/node_modules/grpc/src/client_interceptors.js:841:24)
code: 13,
metadata: Metadata { _internal_repr: {} },
details: 'Internal error.',
note: 'Exception occurred in retry method that was not classified as transient' }

==> err.log <==
ERROR: { Error: 13 INTERNAL: Internal error.
at Object.exports.createStatusError (/root/discord/talkbot/node_modules/grpc/src/common.js:87:15)
at Object.onReceiveStatus (/root/discord/talkbot/node_modules/grpc/src/client_interceptors.js:1188:28)
at InterceptingListener._callNext (/root/discord/talkbot/node_modules/grpc/src/client_interceptors.js:564:42)
at InterceptingListener.onReceiveStatus (/root/discord/talkbot/node_modules/grpc/src/client_interceptors.js:614:8)
at callback (/root/discord/talkbot/node_modules/grpc/src/client_interceptors.js:841:24)
code: 13,
metadata: Metadata { _internal_repr: {} },
details: 'Internal error.',
note: 'Exception occurred in retry method that was not classified as transient' }

Master status reset

When the bot is joined to a new server it resets any active voice users in other servers

!mylang zh-CN on default settings doesn't work

!mylang zh-CN on default settings doesn't work - possibly because Amazon doesn't have a voice that matches this language code

The short term workaround was to explicity set the voice using !myvoice Zhiyu or one of the google voices from !voices cmn

Prepare Sharding

Prepare Sharding.
Load balancing wont work as all connections are open all the time.
Process Sharding...

I'm thinking load the bot with a shard range parameter

for(i in servers.count/20)
     forever app/bot.js --shard-from i --shard-to i+20

permiting `@AI 52519 Hp` from dex's channel caused null

Wokker: hrm it hasn't said anything for you at all

[11:09 AM] Wokker: !unpermit @AI 52519 Hp
[11:09 AM] BOTWokker's New Voice: null talk to the hand
[11:09 AM] Wokker: !permit @AI 52519 Hp
[11:09 AM] BOTWokker's New Voice: I'll listen to @AI 52519

remove big numbers

with long number sequences you get a massively long bit of audio

31342124
The bot has to say
three billion, one million, three hundred and forty two thousand, one hundred and twenty four

could replace something over 9 digits long \d{9,99999}

Bot wouldnt re-join after server disconnect event

Describe the bug
The server shutdown due to a disconnect event.
The bot left voice came back and then left.

To Reproduce
This is difficult to reproduce as it requires the server to send a disconnect event.
Try 'follow and wait'

Expected behavior
Bot should be useable

Screenshots
N/A

Additional context
From the error log:

Error: The connection to the voice channel * has not been initialized yet.
at handleErrCB (/root/projects/talkbot_beta/app/node_modules/discord.io/lib/index.js:1425:25)
at DiscordClient.DCP.getAudioContext (/root/projects/talkbot_beta/app/node_modules/discord.io/lib/index.js:1390:42)
at Immediate.botStuff.tts.synthesizeSpeech (/root/projects/talkbot_beta/app/src/models/Server.js:394:13)
at runCallback (timers.js:803:39)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)

Bot doesn't talk if someone is muted, maybe.

[11:11 AM] Wokker: !permit @AI 52519 Hp
[11:11 AM] BOTWokker's New Voice: I'll listen to @AI 52519 Hp now
[11:11 AM] AI 52519 Hp: Hello?
[11:11 AM] Wokker: testing
[11:11 AM] AI 52519 Hp: huh
[11:11 AM] AI 52519 Hp: !lang ru

Wokker: hrm its not listening to your stuff
[11:06 AM] Wokker: is that because your mic is muted?
[11:07 AM] AI 52519 Hp: do i need to type in a language?
[11:07 AM] Wokker: you should just be able to type in english
[11:07 AM] Wokker: OH ITS BECAUSE YOUR MIC IS MUTED

Filter out long nonsensical repeating characters

maybe have a command !stripAt 5

var message = "abcdefghijklmnooooooopqrstuvwxyz".split('');


var leaveOneRemaining = true;
var thresholdToStartStriping = 4;


var lastletter = '';
var stripLength = leaveOneRemaining?0:1;
for (var i = message.length; i > 0; i--) {
    var letter = message[i - 1];

    if (lastletter == letter) {
        stripLength++;
    } else if (stripLength > thresholdToStartStriping) {
        message.splice(i, stripLength);
        stripLength = leaveOneRemaining?0:1;;
    } else {
        stripLength = leaveOneRemaining?0:1;;
    }
    lastletter = letter;
}

message = message.join('');

The above will return abcdefghijklmnopqrstuvwxyz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.