Skip to content

add /tts - #343

Open
TamHC wants to merge 3 commits into
tbxark:masterfrom
TamHC:master
Open

add /tts#343
TamHC wants to merge 3 commits into
tbxark:masterfrom
TamHC:master

Conversation

@TamHC

@TamHC TamHC commented Jun 24, 2025

Copy link
Copy Markdown
  1. Integrating the /tts command, allowing users to convert written text into spoken audio.

  2. Updated the related configuration to customize the TTS experience according to user preferences.

TamHC added 2 commits June 24, 2025 12:39
add config of TTS

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @TamHC, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new text-to-speech (TTS) feature, enabling users to generate spoken audio from text using a /tts command. It integrates with the OpenAI TTS API, provides comprehensive configuration options for customization, and updates the bot's command handling and documentation to support this new functionality.

Highlights

  • New /tts Command: Users can now convert written text into spoken audio directly via a new /tts command, enhancing the bot's interactive capabilities.
  • Configurable TTS Settings: New configuration options (TTS_API_BASE, TTS_API_KEY, TTS_MODEL, TTS_VOICE, TTS_MODELS_LIST, TTS_VOICES_LIST) have been introduced, allowing for extensive customization of the text-to-speech experience.
  • OpenAI TTS API Integration: The core text-to-speech functionality is powered by the OpenAI TTS API, with a dedicated OpenAITTS class handling requests, API key management, and model/voice selection.
  • Multi-language Command Help: The usage and description for the new /tts command have been added to the help texts in English, Simplified Chinese, and Traditional Chinese, improving accessibility for a wider user base.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces a new /tts command that allows users to convert text to speech. It includes configuration options, API integration with OpenAI's TTS models, and command handling logic. The code appears well-structured and implements the new functionality effectively.

Comment thread dist/index.js
Comment on lines +87 to +94
class TTSConfig {
TTS_API_BASE = "https://api.openai.com/v1";
TTS_API_KEY = [];
TTS_MODEL = "tts-1";
TTS_VOICE = "alloy";
TTS_MODELS_LIST = '["tts-1", "tts-1-hd", "gpt-4o-mini-tts"]';
TTS_VOICES_LIST = '["alloy", "echo", "fable", "nova", "onyx", "shimmer", "ash", "ballad", "coral", "sage"]';
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a brief description for each property in the TTSConfig class to improve readability and maintainability.

class TTSConfig {
  // Base URL for the TTS API
  TTS_API_BASE = "https://api.openai.com/v1";
  // API Key(s) for the TTS API
  TTS_API_KEY = [];
  // Model to use for TTS
  TTS_MODEL = "tts-1";
  // Voice to use for TTS
  TTS_VOICE = "alloy";
  // List of available TTS models
  TTS_MODELS_LIST = '["tts-1", "tts-1-hd", "gpt-4o-mini-tts"]';
  // List of available TTS voices
  TTS_VOICES_LIST = '["alloy", "echo", "fable", "nova", "onyx", "shimmer", "ash", "ballad", "coral", "sage"]';
}

Comment thread dist/index.js
@@ -127,10 +136,10 @@ class EnvironmentConfig {
DEBUG_MODE = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding the tts command to the other language translations as well.

const pt = { "env": { "system_init_message": "Você é um assistente útil" }, "command": { "help": { "summary": "Os seguintes comandos são suportados atualmente:\n", "help": "Obter ajuda sobre comandos", "new": "Iniciar uma nova conversa", "start": "Obter seu ID e iniciar uma nova conversa", "img": "Gerar uma imagem, o formato completo do comando é `/img descrição da imagem`, por exemplo `/img praia ao luar`", "tts": "Gerar áudio de fala, formato `/tts [voz] conteúdo do texto`, por exemplo `/tts alloy Olá Mundo`", "version": "Obter o número da versão atual para determinar se é necessário atualizar", "setenv": "Definir configuração do usuário, o formato completo do comando é /setenv CHAVE=VALOR", "setenvs": 'Definir configurações do usuário em lote, o formato completo do comando é /setenvs {"CHAVE1": "VALOR1", "CHAVE2": "VALOR2"}', "delenv": "Excluir configuração do usuário, o formato completo do comando é /delenv CHAVE", "clearenv": "Limpar todas as configurações do usuário", "system": "Ver algumas informações do sistema", "redo": "Refazer a última conversa, /redo com conteúdo modificado ou diretamente /redo", "echo": "Repetir a mensagem", "models": "Mudar o modelo de diálogo" }, "new": { "new_chat_start": "Uma nova conversa foi iniciada" } }, "callback_query": { "open_model_list": "Abra a lista de modelos", "select_provider": "Escolha um fornecedor de modelos.:", "select_model": "Escolha um modelo:", "change_model": "O modelo de diálogo já foi modificado para" } };

Comment thread dist/index.js
Comment on lines +2744 to +2750
if (message.chat.type === "group" || message.chat.type === "supergroup") {
params.reply_parameters = {
message_id: message.message_id,
chat_id: message.chat.id,
allow_sending_without_reply: true
};
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider simplifying this conditional logic by directly assigning the reply_parameters object based on the chat type.

      const params = {
        chat_id: message.chat.id,
        voice: audioBlob,
        caption: `🎵 語音:${voice}\n📝 文字:${text.length > 100 ? text.substring(0, 100) + '...' : text}`,
        ...(message.chat.type === "group" || message.chat.type === "supergroup") && {
          reply_parameters: {
            message_id: message.message_id,
            chat_id: message.chat.id,
            allow_sending_without_reply: true
          }
        }
      };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant