Skip to content

Commit

Permalink
env for TTS
Browse files Browse the repository at this point in the history
  • Loading branch information
noes14155 committed Nov 24, 2023
1 parent f38d735 commit 6bb759d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@ Default value HG_TEXT2IMAGE = 'stabilityai/stable-diffusion-2-1'
- `DEFAULT_LANG`
Change to your language default english. If you want to translate to your own language please do so in the language_files folder make your own language.yml file and add the language to languages.yml file.

- `Plugins`
- `PLUGINS`
Enable or disable plugins. Default value True.

- `TTS`
Enable or disable TTS. Default value True.

- `BOT_OWNER_ID`
Add your userid from telegram. If empty DM enable or disable option will be disabled.

Expand Down
2 changes: 1 addition & 1 deletion bot/chat_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def fetch_chat_models(self) -> List[str]:
self.models.extend(
model['id']
for model in models_data.get('data')
if "chat" in model['endpoints'][0]

)
else:
print(f"Failed to fetch chat models. Status code: {response.status_code}")
Expand Down
9 changes: 5 additions & 4 deletions bot_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self):
self.HG_TEXT2IMAGE = os.environ.get("HG_TEXT2IMAGE", "stabilityai/stable-diffusion-2-1")
self.DEFAULT_LANGUAGE = os.environ.get("DEFAULT_LANGUAGE", "en")
self.PLUGINS = os.environ.get('PLUGINS', 'true').lower() == 'true'
self.TTS = os.environ.get('TTS', 'true').lower() == 'true'
self.MAX_HISTORY = int(os.environ.get("MAX_HISTORY", 15))
self.API_BASE = os.environ.get("API_BASE", 'https://api.naga.ac/v1')
self.DEFAULT_MODEL = os.environ.get("DEFAULT_MODEL", 'gpt-3.5')
Expand Down Expand Up @@ -221,16 +222,16 @@ async def chat(self, call, waiting_id, bot, process_prompt = ''):
else:
continue
try:
await bot.edit_message_text(chat_id=call.chat.id, message_id=waiting_id, text=full_text, reply_markup=markup)
await bot.edit_message_text(chat_id=call.chat.id, message_id=waiting_id, text=full_text, reply_markup=markup, parse_mode='Markdown')
sent_text = full_text
except Exception:
continue

if full_text not in ['', sent_text]:
await bot.edit_message_text(chat_id=call.chat.id, message_id=waiting_id, text=full_text, reply_markup=markup)
await bot.edit_message_text(chat_id=call.chat.id, message_id=waiting_id, text=full_text, reply_markup=markup, parse_mode='Markdown')
self.cancel_flag = False

await self.generate_tts(full_text, call, bot)
if self.TTS:
await self.generate_tts(full_text, call, bot)
return

async def generate_tts(self, full_text, call, bot):
Expand Down
3 changes: 2 additions & 1 deletion example.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ HG_IMG2TEXT = 'https://api-inference.huggingface.co/models/Salesforce/blip-image
HG_TEXT2IMAGE = 'kandinsky-community/kandinsky-2-2-decoder'
DEFAULT_LANGUAGE = 'en'
DEFAULT_MODEL = 'mistral-7B-openorca'
PLUGINS = True
PLUGINS = 'True'
TTS = 'False'
API_BASE = 'https://api.naga.ac/v1'
MAX_HISTORY = 10
#TEMPERATURE = 0.7
Expand Down

0 comments on commit 6bb759d

Please sign in to comment.