From 54b24781c5689d572f8d22a7e9218d7ccae21b31 Mon Sep 17 00:00:00 2001 From: Bobloy Date: Tue, 15 May 2018 15:41:26 -0400 Subject: [PATCH 1/3] TTS initial commit --- tts/__init__.py | 5 +++++ tts/info..json | 18 ++++++++++++++++++ tts/tts.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 tts/__init__.py create mode 100644 tts/info..json create mode 100644 tts/tts.py diff --git a/tts/__init__.py b/tts/__init__.py new file mode 100644 index 0000000..47959b8 --- /dev/null +++ b/tts/__init__.py @@ -0,0 +1,5 @@ +from .tts import TTS + + +def setup(bot): + bot.add_cog(TTS(bot)) diff --git a/tts/info..json b/tts/info..json new file mode 100644 index 0000000..c762df6 --- /dev/null +++ b/tts/info..json @@ -0,0 +1,18 @@ +{ + "author": [ + "Bobloy" + ], + "bot_version": [ + 3, + 0, + 0 + ], + "description": "Cog Template", + "hidden": true, + "install_msg": "Thank you for installing MyCog", + "requirements": [], + "short": "Cog Template", + "tags": [ + "bobloy" + ] +} \ No newline at end of file diff --git a/tts/tts.py b/tts/tts.py new file mode 100644 index 0000000..49bf494 --- /dev/null +++ b/tts/tts.py @@ -0,0 +1,35 @@ +import io + +import discord +from gtts import gTTS +from redbot.core import Config, commands +from redbot.core.bot import Red + + +class TTS: + """ + V3 Cog Template + """ + + def __init__(self, bot: Red): + self.bot = bot + + self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True) + default_global = {} + default_guild = {} + + self.config.register_global(**default_global) + self.config.register_guild(**default_guild) + + @commands.command(aliases=["t2s", "text2"]) + async def tts(self, ctx: commands.Context, *, text: str): + """ + My custom cog + + Extra information goes here + """ + tts = gTTS(text) + mp3_fp = io.BytesIO() + tts.write_to_fp(mp3_fp) + + await ctx.send("Here's your text", file=discord.File(mp3_fp, "text.mp3")) From 0da2f2df2681901801e24acf67c91f5f697968a7 Mon Sep 17 00:00:00 2001 From: Bobloy Date: Wed, 16 May 2018 08:57:32 -0400 Subject: [PATCH 2/3] getvalue and default language --- tts/tts.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tts/tts.py b/tts/tts.py index 49bf494..dcae0be 100644 --- a/tts/tts.py +++ b/tts/tts.py @@ -28,8 +28,7 @@ class TTS: Extra information goes here """ - tts = gTTS(text) mp3_fp = io.BytesIO() + tts = gTTS(text, 'en') tts.write_to_fp(mp3_fp) - - await ctx.send("Here's your text", file=discord.File(mp3_fp, "text.mp3")) + await ctx.send(file=discord.File(mp3_fp.getvalue(), "text.mp3")) From b12f2a9706d6bb9e24a25eba288da5f41e9b746f Mon Sep 17 00:00:00 2001 From: Bobloy Date: Wed, 16 May 2018 09:00:39 -0400 Subject: [PATCH 3/3] Proper info and release data --- README.md | 1 + tts/info..json | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2ecdf51..2f53825 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Cog Function | secrethitler | **Incomplete** |
Play the Secret Hitler gameConcept, no work done yet
| | stealemoji | **Alpha** |
Steals any custom emoji it sees in a reactionSome planned upgrades for server generation
| | timerole | **Alpha** |
Add roles to members after specified time on the serverUpgraded from V2, please report any bugs
| +| tts | **Alpha** |
Send a Text-to-Speech message as an uploaded mp3Initial release, please report any bugs
| | werewolf | **Alpha** |
Play the classic party game Werewolf within discordAnother massive project currently being developed, will be fully customizable
| diff --git a/tts/info..json b/tts/info..json index c762df6..babe7fc 100644 --- a/tts/info..json +++ b/tts/info..json @@ -7,12 +7,16 @@ 0, 0 ], - "description": "Cog Template", + "description": "Send Text2Speech messages as an uploaded mp3", "hidden": true, - "install_msg": "Thank you for installing MyCog", - "requirements": [], - "short": "Cog Template", + "install_msg": "Thank you for installing TTS. Get started with `[p]tts`", + "requirements": [ + "gTTS" + ], + "short": "Send TTS messages as uploaded mp3", "tags": [ - "bobloy" + "bobloy", + "utils", + "audio" ] } \ No newline at end of file