diff options
Diffstat (limited to '')
| -rw-r--r-- | cogs/tts.py | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/cogs/tts.py b/cogs/tts.py index 46ab637..5e6945c 100644 --- a/cogs/tts.py +++ b/cogs/tts.py | |||
| @@ -6,12 +6,12 @@ | |||
| 6 | import os | 6 | import os |
| 7 | import json | 7 | import json |
| 8 | import discord | 8 | import discord |
| 9 | import aiofiles | ||
| 10 | import logging | 9 | import logging |
| 11 | import tempfile | 10 | import tempfile |
| 12 | from discord.ext import commands | 11 | from discord.ext import commands |
| 13 | from gtts import gTTS | 12 | from gtts import gTTS |
| 14 | import asyncio | 13 | import asyncio |
| 14 | from cogs.utils.settings import get_volume | ||
| 15 | 15 | ||
| 16 | logger = logging.getLogger(__name__) | 16 | logger = logging.getLogger(__name__) |
| 17 | 17 | ||
| @@ -19,18 +19,6 @@ class TTS(commands.Cog): | |||
| 19 | def __init__(self, bot): | 19 | def __init__(self, bot): |
| 20 | self.bot = bot | 20 | self.bot = bot |
| 21 | 21 | ||
| 22 | async def _load_settings(self): | ||
| 23 | """Load volume settings from settings.json""" | ||
| 24 | volume = 1.0 | ||
| 25 | try: | ||
| 26 | async with aiofiles.open('settings.json') as f: | ||
| 27 | content = await f.read() | ||
| 28 | data = json.loads(content) | ||
| 29 | volume = data.get('volume', 1.0) | ||
| 30 | except (json.JSONDecodeError, KeyError, FileNotFoundError) as e: | ||
| 31 | logger.error(f"Error loading settings: {e}") | ||
| 32 | return volume | ||
| 33 | |||
| 34 | async def _handle_file_output(self, ctx, temp_path, text): | 22 | async def _handle_file_output(self, ctx, temp_path, text): |
| 35 | """Handle TTS file output""" | 23 | """Handle TTS file output""" |
| 36 | try: | 24 | try: |
| @@ -109,7 +97,7 @@ class TTS(commands.Cog): | |||
| 109 | tts.save(temp_path) | 97 | tts.save(temp_path) |
| 110 | 98 | ||
| 111 | # Load settings | 99 | # Load settings |
| 112 | volume = await self._load_settings() | 100 | volume = get_volume() |
| 113 | 101 | ||
| 114 | # Handle output based on user choice | 102 | # Handle output based on user choice |
| 115 | if output == "file": | 103 | if output == "file": |
