# "TTS chuyển văn bản thành giọng nói"

Nguồn: https://docs.openaihub.net/api-45208847/

> API origin: `https://api.openaihub.net`. Chọn đúng nhóm API và model. Thông số dưới đây là bản tham chiếu kỹ thuật; chưa phải kết quả kiểm thử từng endpoint bằng tài khoản của bạn.


## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1beta/models/gemini-2.5-flash-preview-tts:generateContent:
    post:
      summary: TTS chuyển văn bản thành giọng nói
      deprecated: false
      description: >-
        Tài liệu chính thức:
        https://ai.google.dev/gemini-api/docs/image-generation?hl=zh-cn#gemini-image-editing
      operationId: gemini_v1beta_2_5_flash_preview_tts_generate_content
      tags:
        - OpenAiHub Việt Nam/OpenAiHub Tiếng Việt/Trò chuyện/Gemini/Định dạng gốc
        - Gemini v1beta
      parameters:
        - name: key
          in: query
          description: 'Khóa API (cũng hỗ trợ Authorization: Bearer)'
          required: true
          example: '{{YOUR_API_KEY}}'
          schema:
            type: string
        - name: Content-Type
          in: header
          description: >-
            Kiểu nội dung của phần thân yêu cầu, được cố định là
            application/json
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - contents
                - generationConfig
              properties:
                contents:
                  type: array
                  items:
                    type: object
                    properties:
                      parts:
                        type: array
                        items:
                          type: object
                          properties:
                            inline_data:
                              type: object
                              required:
                                - mime_type
                                - data
                              properties:
                                data:
                                  type: string
                                  description: >-
                                    Dữ liệu phương tiện được mã hóa Base64
                                    (không có tiền tố data:)
                                mime_type:
                                  type: string
                                  description: >-
                                    Loại MIME của phương tiện, ví dụ: audio/wav,
                                    audio/mpeg
                              description: >-
                                Dữ liệu nhị phân nội tuyến (ví dụ: âm thanh tham
                                chiếu); không bắt buộc đối với TTS thuần túy
                              x-apifox-orders:
                                - data
                                - mime_type
                              x-apidog-orders:
                                - data
                                - mime_type
                            text:
                              type: string
                              description: Nội dung văn bản để tổng hợp thành giọng nói
                          description: >-
                            Dịch tài liệu kỹ thuật này sang tiếng Việt. Giữ
                            nguyên Markdown, mã, định danh, URL, đường dẫn, phần
                            giữ chỗ, cấu trúc JSON và định dạng. Chỉ trả về văn
                            bản đã dịch và không để lại bất kỳ ký tự Hán nào.


                            Một phần duy nhất; sử dụng văn bản và/hoặc
                            inline_data
                          x-apifox-orders:
                            - inline_data
                            - text
                          x-apidog-orders:
                            - inline_data
                            - text
                        description: >-
                          Các phần nội dung; TTS chủ yếu sử dụng văn bản; có thể
                          bao gồm âm thanh tham chiếu `inline_data` nếu hệ thống
                          nguồn hỗ trợ
                    description: Nội dung một lượt (vai trò mặc định là người dùng)
                    x-apifox-orders:
                      - parts
                    x-apidog-orders:
                      - parts
                  description: >-
                    Nội dung cuộc trò chuyện; TTS thường cần một tin nhắn của
                    người dùng chứa văn bản để đọc thành từng phần
                generationConfig:
                  type: object
                  required:
                    - responseModalities
                  properties:
                    responseModalities:
                      type: array
                      items:
                        type: string
                        description: >-
                          Tên phương thức, thường là AUDIO; có thể kết hợp với
                          TEXT, v.v. tùy theo mô hình
                      description: >-
                        Các phương thức phản hồi; đối với TTS, hãy sử dụng
                        ["AUDIO"]
                    speechConfig:
                      type: object
                      required:
                        - voiceConfig
                      properties:
                        voiceConfig:
                          type: object
                          required:
                            - prebuiltVoiceConfig
                          properties:
                            prebuiltVoiceConfig:
                              type: object
                              required:
                                - voiceName
                              properties:
                                voiceName:
                                  type: string
                                  description: >-
                                    Tên giọng nói cài sẵn, ví dụ: Kore, Puck,
                                    Charon, Fenrir, Aoede
                              description: >-
                                Vui lòng cung cấp nội dung tài liệu kỹ thuật cần
                                dịch.
                              x-apifox-orders:
                                - voiceName
                              x-apidog-orders:
                                - voiceName
                          description: Cấu hình giọng nói
                          x-apifox-orders:
                            - prebuiltVoiceConfig
                          x-apidog-orders:
                            - prebuiltVoiceConfig
                      description: >-
                        Cấu hình tổng hợp giọng nói; các tùy chọn về giọng đọc
                        và cách phát âm
                      x-apifox-orders:
                        - voiceConfig
                      x-apidog-orders:
                        - voiceConfig
                  description: >-
                    Cấu hình tạo sinh; TTS phải khai báo phương thức AUDIO và
                    cấu hình giọng nói
                  x-apifox-orders:
                    - responseModalities
                    - speechConfig
                  x-apidog-orders:
                    - responseModalities
                    - speechConfig
              refName: PostV1betaModelsGemini25FlashPreviewTtsGenerateContentRequest
              description: >-
                Nội dung yêu cầu chuyển văn bản thành giọng nói của Gemini 2.5
                Flash Preview TTS
              x-apifox-orders:
                - contents
                - generationConfig
              x-apidog-orders:
                - contents
                - generationConfig
            examples:
              gemini_2_5_flash_preview_tts:
                value:
                  contents:
                    - parts:
                        - text: Nói ra,tôi là ai,ai là tôi
                  generationConfig:
                    responseModalities:
                      - ÂM THANH
                    speechConfig:
                      voiceConfig:
                        prebuiltVoiceConfig:
                          voiceName: Kore
                  model: gemini-2.5-flash-preview-tts
                summary: gemini_2_5_flash_preview_tts
                description: TTS chuyển văn bản thành giọng nói
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                x-apidog-orders: []
              examples:
                example:
                  summary: example
                  value:
                    id: resp_example
                    object: phản hồi
                    status: completed
          headers: {}
          x-apidog-name: ''
        '400':
          description: Yêu cầu không hợp lệ hoặc xác thực thất bại
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - message
                      - type
                    properties:
                      message:
                        type: string
                        description: Thông báo lỗi (thường kết thúc bằng mã yêu cầu)
                      type:
                        type: string
                        description: Loại lỗi; các lỗi cổng cục bộ thường là new_api_error
                        examples:
                          - new_api_error
                    x-apifox-orders:
                      - message
                      - type
                    x-apidog-orders:
                      - message
                      - type
                refName: NewApiError
                x-apifox-orders:
                  - error
                x-apidog-orders:
                  - error
              examples:
                example:
                  summary: example
                  value:
                    error:
                      message: >-
                        Yêu cầu không hợp lệ (mã yêu cầu:
                        20260805120000123456789AbCdEfGh)
                      type: new_api_error
          headers: {}
          x-apidog-name: Yêu cầu không hợp lệ hoặc xác thực thất bại
        '401':
          description: Khóa API bị thiếu hoặc không hợp lệ
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - message
                      - type
                    properties:
                      message:
                        type: string
                        description: Thông báo lỗi (thường kết thúc bằng mã yêu cầu)
                      type:
                        type: string
                        description: Loại lỗi; các lỗi cổng cục bộ thường là new_api_error
                        examples:
                          - new_api_error
                    x-apifox-orders:
                      - message
                      - type
                    x-apidog-orders:
                      - message
                      - type
                refName: NewApiError
                x-apifox-orders:
                  - error
                x-apidog-orders:
                  - error
              examples:
                example:
                  summary: example
                  value:
                    error:
                      message: >-
                        Mã thông báo không hợp lệ (request id:
                        20260805120000123456789AbCdEfGh)
                      type: new_api_error
          headers: {}
          x-apidog-name: Khóa API bị thiếu hoặc không hợp lệ
      security: []
      x-apidog-folder: OpenAiHub Việt Nam/OpenAiHub Tiếng Việt/Trò chuyện/Gemini/Định dạng gốc
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1218648/apis/api-45208847-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: https://api.openaihub.net
    description: Prod Env
security: []

```
