### Starting the Server with Default and Overridden Settings Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Provides commands to install dependencies and start the API server, demonstrating how to use environment variables for configuration overrides. ```bash # Install dependencies pip install -r requirements.txt # Start with default settings (SQLite, Faster-Whisper large-v3, port 80) python start.py # Or with environment overrides DB_TYPE=mysql \ MYSQL_DB_NAME=whisper \ MYSQL_USERNAME=root \ MYSQL_PASSWORD=secret \ MYSQL_HOST=127.0.0.1 \ OPENAI_API_KEY=sk-... # DOUYIN_WEB_COOKIE="your_cookie_here" \ python start.py # Interactive Swagger UI is served at http://localhost/ ``` -------------------------------- ### Install httpx for API Requests Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Install the httpx library, which is required for making HTTP requests to the API. ```bash pip install httpx ``` -------------------------------- ### Start the API Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Starts the FastAPI application. Ensure you are in the root project directory. The API documentation will be accessible at http://127.0.0.1/. ```bash python3 start.py ``` -------------------------------- ### Install FFmpeg on Arch Linux Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Installs FFmpeg on Arch Linux. This is required for audio and video processing. ```bash sudo pacman -S ffmpeg ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Installs all required Python dependencies from the requirements file. Navigate to the project directory first. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install FFmpeg on Ubuntu/Debian Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Installs FFmpeg on Ubuntu or Debian-based systems. This is required for audio and video processing. ```bash sudo apt update && sudo apt install ffmpeg ``` -------------------------------- ### Install FFmpeg on Windows (Scoop) Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Installs FFmpeg on Windows using Scoop. This is required for audio and video processing. ```bash scoop install ffmpeg ``` -------------------------------- ### Install FFmpeg on Windows (Chocolatey) Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Installs FFmpeg on Windows using Chocolatey. This is required for audio and video processing. ```bash choco install ffmpeg ``` -------------------------------- ### Install FFmpeg on MacOS Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Installs FFmpeg on MacOS using Homebrew. This is required for audio and video processing. ```bash brew install ffmpeg ``` -------------------------------- ### Clone Project Repository Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Use this command to clone the project repository. Ensure Git is installed. ```bash git clone https://github.com/Evil0ctal/Fast-Powerful-Whisper-AI-Services-API.git ``` -------------------------------- ### Install PyTorch with CUDA Support Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Installs PyTorch, Torchvision, and Torchaudio with CUDA 12.1 support. Ensure your CUDA Toolkit version matches your GPU. ```bash pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 ``` -------------------------------- ### Add TikTok Video Task (Python) Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Use this Python script with the `httpx` library to add a video task to the TikTok processing queue. Install `httpx` using `pip install httpx`. ```python # pip install httpx import httpx url = "http://127.0.0.1/api/tiktok/video_task" tiktok_url = "https://www.tiktok.com/@taylorswift/video/7359655005701311786" ``` -------------------------------- ### API Response for Task Result Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md This is an example JSON response from the API endpoint when a task has been completed. It includes details about the task, file processing, and the transcription result, including language detection and confidence scores. ```json { "code": 200, "router": "http://127.0.0.1/api/whisper/tasks/result?task_id=1", "params": { "task_id": "1" }, "data": { "id": 1, "status": "completed", "callback_url": "", "callback_status_code": null, "callback_message": null, "callback_time": null, "priority": "normal", "engine_name": "faster_whisper", "task_type": "transcribe", "created_at": "2024-11-07T16:43:33", "updated_at": "2024-11-07T16:43:33", "task_processing_time": 6.20258, "file_path": "C:\\Users\\Evil0ctal\\PycharmProjects\\Fast-Powerful-Whisper-AI-Services-API\\temp_files\\5accc0958ec7476e81d06f8c3897d768.mp4", "file_url": "https://api.tiktokv.com/aweme/v1/play/?file_id=3146fc434e4d493c93b78566726b9310&is_play_url=1&item_id=7359655005701311786&line=0&signaturev3=dmlkZW9faWQ7ZmlsZV9pZDtpdGVtX2lkLjA3YTkzYjY0ZTliOWUzMzVmN2VhODgxMTMyMDljYTJk&source=FEED&vidc=useast5&video_id=v12044gd0000cohbuanog65ltpj9jdpg", "file_name": null, "file_size_bytes": 2401593, "file_duration": 30.071, "language": "en", "platform": "tiktok", "decode_options": { "language": null, "temperature": [ 0.8, 1 ], "initial_prompt": "", "clip_timestamps": "0.0", "word_timestamps": false, "append_punctuations": "\"'.。,,!!??::”)]}、", "no_speech_threshold": 0.6, "prepend_punctuations": "\'\"“¿([{-", "condition_on_previous_text": true, "compression_ratio_threshold": 1.8, "hallucination_silence_threshold": null }, "error_message": null, "output_url": "http://127.0.0.1/api/whisper/tasks/result?task_id=1", "result": { "info": { "duration": 30.07125, "language": "en", "vad_options": null, "all_language_probs": [ [ "en", 0.986328125 ], [ "es", 0.0013828277587890625 ], [ "ja", 0.00125885009765625 ], [ "fr", 0.0012197494506835938 ], [ "de", 0.0010852813720703125 ], [ "la", 0.0010519027709960938 ], [ "zh", 0.00089263916015625 ], [ "pt", 0.0008320808410644531 ], [ "ko", 0.000751495361328125 ], [ "cy", 0.000751495361328125 ], [ "ru", 0.00074005126953125 ], [ "nn", 0.0005245208740234375 ], [ "sv", 0.00036072731018066406 ], [ "it", 0.0002853870391845703 ], [ "vi", 0.00024580955505371094 ], [ "tr", 0.0002310276031494141 ], [ "nl", 0.00017440319061279297 ], [ "pl", 0.00015997886657714844 ], [ "jw", 0.0001480579376220703 ], [ "hi", 0.00012755393981933594 ], [ "ar", 0.00012362003326416016 ], [ "km", 0.00012362003326416016 ], [ "fi", 0.0001189112663269043 ], [ "id", 0.0001170635223388672 ], [ "haw", 0.00009781122207641602 ], [ "th", 0.00009119510650634766 ], [ "hu", 0.00007158517837524414 ], [ "tl", 0.000056624412536621094 ], [ "el", 0.00005316734313964844 ], [ "no", 0.000051975250244140625 ], [ "ms", 0.00003892183303833008 ], [ "cs", 0.00003802776336669922 ], [ "ro", 0.00003129243850708008 ], [ "ta", 0.00002312660217285156 ], [ "mi", 0.000019674301147460938 ] ] } } } } ``` -------------------------------- ### API Response for TikTok Video Transcription Task Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Example JSON response from the API after submitting a transcription task. It includes task details, processing options, and status. ```json { "code":200, "router":"http://127.0.0.1/api/tiktok/video_task", "params":{ "language":null, "temperature":[ 0.8, 1 ], "compression_ratio_threshold":1.8, "no_speech_threshold":0.6, "condition_on_previous_text":true, "initial_prompt":"", "word_timestamps":false, "prepend_punctuations":"\"'\u201c\u00bf([{-", "append_punctuations":"\"'.\u3002\uff0c!\uff01? ?: :\u201d)]}\u3001", "clip_timestamps":"0.0", "hallucination_silence_threshold":null, "task_type":"transcribe", "priority":"normal", "callback_url":"" }, "data":{ "id":1, "status":"queued", "callback_url":"", "callback_status_code":null, "callback_message":null, "callback_time":null, "priority":"normal", "engine_name":"faster_whisper", "task_type":"transcribe", "created_at":"2024-11-07T16:43:32.768883", "updated_at":"2024-11-07T16:43:32.768883", "task_processing_time":null, "file_path":null, "file_url":"https://api.tiktokv.com/aweme/v1/play/?file_id=3146fc434e4d493c93b78566726b9310&is_play_url=1&item_id=7359655005701311786&line=0&signaturev3=dmlkZW9faWQ7ZmlsZV9pZDtpdGVtX2lkLjA3YTkzYjY0ZTliOWUzMzVmN2VhODgxMTMyMDljYTJk&source=FEED&vidc=useast5&video_id=v12044gd0000cohbuanog65ltpj9jdpg", "file_name":null, "file_size_bytes":null, "file_duration":null, "language":null, "platform":"tiktok", "decode_options":{ "language":null, "temperature":[ 0.8, 1 ], "compression_ratio_threshold":1.8, "no_speech_threshold":0.6, "condition_on_previous_text":true, "initial_prompt":"", "word_timestamps":false, "prepend_punctuations":"\"'\u201c\u00bf([{-", "append_punctuations":"\"'.\u3002\uff0c!\uff01? ?: :\u201d)]}\u3001", "clip_timestamps":"0.0", "hallucination_silence_threshold":null }, "error_message":null, "output_url":"http://127.0.0.1/api/whisper/tasks/result?task_id=1", "result":null } } ``` -------------------------------- ### Get Task Result Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Retrieves the result of a previously created task by its numeric ID. Returns HTTP 200 with full transcript data when complete, HTTP 202 while queued or processing, HTTP 404 if not found, and HTTP 500 if the task failed. ```bash curl -X GET "http://localhost/api/whisper/tasks/result?task_id=42" # HTTP 200 – completed # { # "code": 200, # "data": { # "id": 42, # "status": "completed", # "language": "zh", # "task_processing_time": 1.78, # "file_duration": 11.77, # "result": { # "transcription": "吃饭了吗 吃饭了 等我吃完饭再来找你玩哦 好", # "segments": [ # {"id": 1, "start": 0.0, "end": 2.3, "text": "吃饭了吗"}, # ... # ], # "info": {"language": "zh", "language_probability": 0.974, "duration": 11.77} # } # } # } # HTTP 202 – still processing # {"code": 202, "message": "Task is currently being processed"} # HTTP 404 – not found # {"code": 404, "message": "Task not found or has been deleted or invalid task ID"} ``` -------------------------------- ### Make Asynchronous API Request for Task Result Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md This Python code snippet demonstrates how to make an asynchronous GET request to the API to retrieve the result of a transcription task. It requires the httpx and asyncio libraries. Ensure the API is running locally at the specified URL. ```python import httpx url = "http://127.0.0.1/api/whisper/tasks/result" task_id = 1 params = { "task_id": task_id } async def make_request(): async with httpx.AsyncClient() as client: response = await client.get(url, params=params) print(response.json()) if __name__ == "__main__": # To run the async function import asyncio # Run the async function asyncio.run(make_request()) ``` -------------------------------- ### Import Libraries for Configuration Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Imports necessary libraries for environment variable loading and type hinting in Python configuration files. ```python import os from typing import Optional from dotenv import load_dotenv ``` -------------------------------- ### Create Douyin Video Task Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Similar to the TikTok endpoint, this processes Douyin videos using `DouyinWebCrawler`. It resolves short share links to direct video streams and requires a `DOUYIN_WEB_COOKIE` environment variable for authentication. ```bash curl -X POST "http://localhost/api/douyin/video_task" \ -F "url=https://v.douyin.com/iANRkr9m/" \ -F "task_type=transcribe" \ -F "priority=high" \ -F "language=zh" \ -F "save_data_in_db=true" ``` -------------------------------- ### Get Transcription Task Result (CURL) Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Use this CURL command to retrieve the transcription result for a given task ID from the API. ```curl curl -X 'GET' \ 'http://127.0.0.1/api/whisper/tasks/result?task_id=1' \ -H 'accept: application/json' ``` -------------------------------- ### Get Transcription Task Result (Python) Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Python code snippet to fetch the transcription result for a specific task ID using the API. ```python import httpx async def get_result(task_id): async with httpx.AsyncClient() as client: response = await client.get(f"http://127.0.0.1/api/whisper/tasks/result?task_id={task_id}") print(response.json()) if __name__ == "__main__": import asyncio asyncio.run(get_result(1)) ``` -------------------------------- ### Create Douyin (Chinese TikTok) Video Task Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Works identically to the TikTok endpoint but uses the `DouyinWebCrawler` and resolves short share links to direct video stream URLs. ```APIDOC ## Create Douyin (Chinese TikTok) Video Task ### `POST /api/douyin/video_task` Works identically to the TikTok endpoint but uses the `DouyinWebCrawler` and resolves short share links (e.g. `https://v.douyin.com/...`) to direct video stream URLs. Requires a valid Douyin web cookie configured via the `DOUYIN_WEB_COOKIE` environment variable. ```bash curl -X POST "http://localhost/api/douyin/video_task" \ -F "url=https://v.douyin.com/iANRkr9m/" \ -F "task_type=transcribe" \ -F "priority=high" \ -F "language=zh" \ -F "save_data_in_db=true" # HTTP 200 # {"code": 200, "data": {"id": 44, "status": "queued", "platform": "douyin", ...}} ``` ``` -------------------------------- ### Fetch Next Page of Tasks Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Use this endpoint to retrieve the next set of completed tasks, specifying the desired limit and offset for pagination. ```bash curl -X POST "http://localhost/api/whisper/tasks/query" \ -H "Content-Type: application/json" \ -d '{"status": "completed", "limit": 10, "offset": 10}' ``` -------------------------------- ### Get Transcription Task Result Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Retrieves the transcription result for a given task ID. This endpoint is used to fetch the final output after a transcription task has been processed. ```APIDOC ## GET /api/whisper/tasks/result ### Description Retrieves the transcription result for a specified task ID. ### Method GET ### Endpoint /api/whisper/tasks/result ### Parameters #### Query Parameters - **task_id** (integer) - Required - The unique identifier for the transcription task. ### Response #### Success Response (200) - **result** (any) - The transcription result, which can be text or other relevant data. ### Request Example (CURL) ```curl curl -X 'GET' \ 'http://127.0.0.1/api/whisper/tasks/result?task_id=1' \ -H 'accept: application/json' ``` ### Request Example (Python) ```python import httpx async def get_task_result(task_id: int): async with httpx.AsyncClient() as client: response = await client.get(f"http://127.0.0.1/api/whisper/tasks/result?task_id={task_id}") response.raise_for_status() # Raise an exception for bad status codes return response.json() # Example usage: # import asyncio # task_id_to_retrieve = 1 # result = asyncio.run(get_task_result(task_id_to_retrieve)) # print(result) ``` ``` -------------------------------- ### Create Whisper Transcription Task (File Upload) Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Accepts a media file upload or a `file_url` query parameter to enqueue an asynchronous Whisper task. Poll `/api/whisper/tasks/result?task_id=` for the outcome. Supported `task_type` values are `transcribe` and `translate`. Priority levels are `low`, `normal`, and `high`. Provide a `callback_url` to receive a POST webhook once the task finishes. ```bash # Transcribe a local audio file at normal priority curl -X POST "http://localhost/api/whisper/tasks/create" \ -F "file=@/path/to/audio.mp3" \ -F "task_type=transcribe" \ -F "priority=normal" \ -F "language=en" \ -F "temperature=0.2" \ -F "word_timestamps=false" \ -F "callback_url=http://localhost/api/whisper/callback/test" ``` ```bash # Transcribe from a remote URL at high priority curl -X POST "http://localhost/api/whisper/tasks/create?file_url=https://example.com/video.mp4&task_type=transcribe&priority=high&language=" # Expected response (HTTP 200) # { # "code": 200, # "router": "http://localhost/api/whisper/tasks/create", # "params": {"task_type": "transcribe", "priority": "normal", ...}, # "data": { # "id": 42, # "status": "queued", # "engine_name": "faster_whisper", # "task_type": "transcribe", # "priority": "normal", # "created_at": "2024-11-01T00:37:15.319257", # "output_url": "http://localhost/api/whisper/tasks/result?task_id=42", # ... # } # } ``` -------------------------------- ### Generate Subtitle File (SRT/WebVTT) Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Generates an SRT or WebVTT subtitle file from a completed task's time-stamped segments. Requires the task to have word-level or segment-level timestamps in its result. Specify the task ID and desired output format. ```bash # Download SRT subtitles for task 42 curl -X GET "http://localhost/api/whisper/generate_subtitles?task_id=42&output_format=srt" \ --output subtitles.srt # Download WebVTT subtitles curl -X GET "http://localhost/api/whisper/generate_subtitles?task_id=42&output_format=vtt" \ --output subtitles.vtt ``` -------------------------------- ### ChatGPT Content Summarization Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Submits a completed task's transcript text to the OpenAI ChatGPT API for summarization. Allows customization of API key, model, prompt, and output language, with an option to save the summary to the database. ```bash curl -X POST "http://localhost/api/chatgpt/summary" \ -H "Content-Type: application/json" \ -d '{ "task_id": 42, "chatgpt_api_key": "sk-...". "chatgpt_model": "gpt-4o", "chatgpt_prompt": "Summarize the key points discussed in this audio.", "output_language": "English", "save_to_database": true }' ``` -------------------------------- ### Get Task Result Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Retrieves the result of a previously created task by its numeric ID. Returns HTTP 200 with full transcript data when complete, HTTP 202 while queued or processing, HTTP 404 if not found, and HTTP 500 if the task failed. ```APIDOC ## GET /api/whisper/tasks/result ### Description Retrieves the result of a previously created task by its numeric ID. Returns HTTP 200 with full transcript data when complete, HTTP 202 while queued or processing, HTTP 404 if not found, and HTTP 500 if the task failed. ### Method GET ### Endpoint /api/whisper/tasks/result ### Parameters #### Query Parameters - **task_id** (integer) - Required - The unique identifier of the task. ### Response #### Success Response (200) - **code** (integer) - HTTP status code (200 for success). - **data** (object) - Contains the task result details: - **id** (integer) - The task ID. - **status** (string) - The final status of the task (`completed`). - **language** (string) - The detected or specified language of the audio. - **task_processing_time** (number) - The time taken to process the task in seconds. - **file_duration** (number) - The duration of the audio file in seconds. - **result** (object) - The transcription or translation result: - **transcription** (string) - The full transcribed or translated text. - **segments** (array) - An array of segment objects, each containing `id`, `start`, `end`, and `text`. - **info** (object) - Contains additional information like detected `language` and `language_probability`, and `duration`. #### Processing Response (202) - **code** (integer) - HTTP status code (202 for processing). - **message** (string) - Indicates the task is still being processed. #### Not Found Response (404) - **code** (integer) - HTTP status code (404 for not found). - **message** (string) - Indicates the task was not found or is invalid. ### Request Example ```bash curl -X GET "http://localhost/api/whisper/tasks/result?task_id=42" ``` ### Response Example (HTTP 200 - completed) ```json { "code": 200, "data": { "id": 42, "status": "completed", "language": "zh", "task_processing_time": 1.78, "file_duration": 11.77, "result": { "transcription": "吃饭了吗 吃饭了 等我吃完饭再来找你玩哦 好", "segments": [ {"id": 1, "start": 0.0, "end": 2.3, "text": "吃饭了吗"}, ... ], "info": {"language": "zh", "language_probability": 0.974, "duration": 11.77} } } } ``` ### Response Example (HTTP 202 - still processing) ```json { "code": 202, "message": "Task is currently being processed" } ``` ### Response Example (HTTP 404 - not found) ```json { "code": 404, "message": "Task not found or has been deleted or invalid task ID" } ``` ``` -------------------------------- ### Extract Audio from Video Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Accepts a video file upload and extracts audio, returning it as a downloadable WAV or MP3 file. Temporary files are automatically deleted after the response is sent. Specify sample rate, bit depth, and output format as needed. ```bash curl -X POST "http://localhost/api/whisper/extract_audio" \ -F "file=@/path/to/video.mp4" \ -F "sample_rate=44100" \ -F "bit_depth=2" \ -F "output_format=mp3" \ --output extracted_audio.mp3 ``` -------------------------------- ### Create a Whisper Transcription Task Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Accepts a media file upload or a `file_url` query parameter, enqueues an asynchronous Whisper task, and returns the new task record. The task is not processed synchronously; poll `/api/whisper/tasks/result?task_id=` for the outcome. Supported `task_type` values are `transcribe` and `translate`. Priority levels are `low`, `normal`, and `high`. Provide a `callback_url` to receive a POST webhook once the task finishes. ```APIDOC ## POST /api/whisper/tasks/create ### Description Accepts a media file upload or a `file_url` query parameter, enqueues an asynchronous Whisper task, and returns the new task record. The task is not processed synchronously; poll `/api/whisper/tasks/result?task_id=` for the outcome. Supported `task_type` values are `transcribe` and `translate`. Priority levels are `low`, `normal`, and `high`. Provide a `callback_url` to receive a POST webhook once the task finishes. ### Method POST ### Endpoint /api/whisper/tasks/create ### Parameters #### Query Parameters - **file_url** (string) - Optional - URL of the media file to process. - **language** (string) - Optional - The language of the audio. If not specified, the language is detected automatically. - **task_type** (string) - Required - The type of task to perform. Supported values: `transcribe`, `translate`. - **priority** (string) - Optional - The priority of the task. Supported values: `low`, `normal`, `high`. Defaults to `normal`. - **callback_url** (string) - Optional - A URL to receive a webhook notification when the task is completed. - **temperature** (number) - Optional - Controls randomness. Lower values make the model more deterministic. Defaults to 0.0. - **word_timestamps** (boolean) - Optional - Whether to include word-level timestamps in the output. Defaults to `false`. #### Request Body - **file** (file) - Required if `file_url` is not provided - The media file to upload for processing. ### Request Example ```bash # Transcribe a local audio file at normal priority curl -X POST "http://localhost/api/whisper/tasks/create" \ -F "file=@/path/to/audio.mp3" \ -F "task_type=transcribe" \ -F "priority=normal" \ -F "language=en" \ -F "temperature=0.2" \ -F "word_timestamps=false" \ -F "callback_url=http://localhost/api/whisper/callback/test" # Transcribe from a remote URL at high priority curl -X POST "http://localhost/api/whisper/tasks/create?file_url=https://example.com/video.mp4&task_type=transcribe&priority=high&language=" ``` ### Response #### Success Response (200) - **code** (integer) - HTTP status code. - **router** (string) - The endpoint that was called. - **params** (object) - The parameters used for the task. - **data** (object) - Contains the task details: - **id** (integer) - The unique identifier for the task. - **status** (string) - The current status of the task (e.g., `queued`, `processing`, `completed`, `failed`). - **engine_name** (string) - The name of the inference engine used (e.g., `faster_whisper`). - **task_type** (string) - The type of task performed (`transcribe` or `translate`). - **priority** (string) - The priority level of the task. - **created_at** (string) - Timestamp when the task was created. - **output_url** (string) - URL to poll for the task result. #### Response Example ```json { "code": 200, "router": "http://localhost/api/whisper/tasks/create", "params": {"task_type": "transcribe", "priority": "normal", ...}, "data": { "id": 42, "status": "queued", "engine_name": "faster_whisper", "task_type": "transcribe", "priority": "normal", "created_at": "2024-11-01T00:37:15.319257", "output_url": "http://localhost/api/whisper/tasks/result?task_id=42", ... } } ``` ``` -------------------------------- ### Test Callback Interface Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt This endpoint echoes a POST request body, useful for testing callback URLs during task creation. The API server sends full task data to the provided callback URL upon completion. ```bash # Set as callback_url during task creation (server will POST to this endpoint): curl -X POST "http://localhost/api/whisper/tasks/create" \ -F "file=@audio.mp3" \ -F "callback_url=http://localhost/api/whisper/callback/test" # Manually test the endpoint with custom payload: curl -X POST "http://localhost/api/whisper/callback/test" \ -H "Content-Type: application/json" \ -d '{ "id": 1, "status": "completed", "task_type": "transcribe", "engine_name": "faster_whisper", "result": {"transcription": "Hello world", "segments": []} }' ``` -------------------------------- ### API Configuration Settings Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Defines runtime behavior and environment variable overrides for various API components like FastAPI, database, model pooling, whisper engines, and external services. ```python # config/settings.py – primary configuration reference class Settings: class FastAPISettings: title = "Fast-Powerful-Whisper-AI-Services-API" version = "1.0.5" ip = "0.0.0.0" port = 80 # Override: RELOAD_ON_FILE_CHANGE=true class DatabaseSettings: db_type = "sqlite" # or "mysql" – Override: DB_TYPE=mysql # SQLite (default): WhisperServiceAPI.db # MySQL overrides: MYSQL_DB_NAME, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_HOST class AsyncModelPoolSettings: engine = "faster_whisper" # or "openai_whisper" min_size = 1 max_size = 1 # increase for multi-GPU max_instances_per_gpu = 1 init_with_max_pool_size = True class FasterWhisperSettings: faster_whisper_model_size_or_path = "large-v3" faster_whisper_device = "auto" # "cpu" | "cuda" | "auto" faster_whisper_compute_type = "float16" faster_whisper_cpu_threads = 0 # 0 = all available class OpenAIWhisperSettings: openai_whisper_model_name = "large-v3" openai_whisper_device = None # None = auto class WhisperServiceSettings: MAX_CONCURRENT_TASKS = 1 TASK_STATUS_CHECK_INTERVAL = 3 # seconds class ChatGPTSettings: API_Key = "" # Override: OPENAI_API_KEY GPT_Model = "gpt-3.5-turbo" class DouyinAPISettings: web_cookie = "" # Override: DOUYIN_WEB_COOKIE proxy = None # Override: DOUYIN_PROXY class TikHubAPISettings: api_domain = "https://api.tikhub.io" api_key = "" # Override: TIKHUB_API_KEY ``` -------------------------------- ### Query Tasks with Filters Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Paginated query over all stored tasks. Supports filtering by status, priority, date range, language, engine name, and whether a result or error is present. Returns a list of matching tasks, total count, and a `next_offset` for cursor-based pagination. ```bash curl -X POST "http://localhost/api/whisper/tasks/query" \ -H "Content-Type: application/json" \ -d '{ "status": "completed", "priority": "normal", "engine_name": "faster_whisper", "language": "en", "has_result": true, "has_error": false, "limit": 10, "offset": 0 }' # Expected response # { # "code": 200, # "data": { # "tasks": [{"id": 1, "status": "completed", ...}, ...], # "total_count": 55, # "has_more": true, # "next_offset": 10 # } # } ``` -------------------------------- ### ChatGPT Content Summarization Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Takes a completed task ID and submits its transcript text to the OpenAI ChatGPT API for summarization. ```APIDOC ## ChatGPT Content Summarization ### `POST /api/chatgpt/summary` Takes a completed task ID and submits its transcript text to the OpenAI ChatGPT API for summarization. Accepts a custom API key, model override, prompt, and output language. The summary result is optionally saved to the database linked to the task ID. ```bash curl -X POST "http://localhost/api/chatgpt/summary" \ -H "Content-Type: application/json" \ -d '{ "task_id": 42, "chatgpt_api_key": "sk-...", "chatgpt_model": "gpt-4o", "chatgpt_prompt": "Summarize the key points discussed in this audio.", "output_language": "English", "save_to_database": true }' ``` ``` -------------------------------- ### Fetch next page of tasks Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Retrieves the next page of tasks based on status, limit, and offset. ```APIDOC ## Fetch next page ```bash curl -X POST "http://localhost/api/whisper/tasks/query" \ -H "Content-Type: application/json" \ -d '{"status": "completed", "limit": 10, "offset": 10}' ``` ``` -------------------------------- ### Create TikTok Video Task Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Crawls a TikTok video by its share URL, extracts the highest-quality playback stream, and initiates a Whisper task. Optionally saves raw API response data and sets a callback URL for notifications. ```bash curl -X POST "http://localhost/api/tiktok/video_task" \ -F "url=https://www.tiktok.com/@taylorswift/video/7359655005701311786" \ -F "task_type=transcribe" \ -F "priority=normal" \ -F "language=" \ -F "save_data_in_db=true" \ -F "callback_url=http://localhost/api/whisper/callback/test" # Poll for result curl -X GET "http://localhost/api/whisper/tasks/result?task_id=43" ``` -------------------------------- ### Check Server Health Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Verifies that the FastAPI server is running and accepting requests. Returns `{"status": "ok"}` with HTTP 200 when healthy. ```bash curl -X GET http://localhost/api/health/check # Expected response # HTTP 200 # {"status": "ok"} ``` -------------------------------- ### Test Callback Interface Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Receives and echoes a callback POST request body. Use this endpoint URL as the `callback_url` when creating a task to inspect the webhook payload in server logs. ```APIDOC ## Test Callback Interface ### `POST /api/whisper/callback/test` Receives and echoes a callback POST request body. Use this endpoint URL as the `callback_url` when creating a task to inspect the webhook payload in server logs. The API server POSTs full task data to this URL once processing completes. ```bash # Set as callback_url during task creation (server will POST to this endpoint): curl -X POST "http://localhost/api/whisper/tasks/create" \ -F "file=@audio.mp3" \ -F "callback_url=http://localhost/api/whisper/callback/test" # Manually test the endpoint with custom payload: curl -X POST "http://localhost/api/whisper/callback/test" \ -H "Content-Type: application/json" \ -d '{ "id": 1, "status": "completed", "task_type": "transcribe", "engine_name": "faster_whisper", "result": {"transcription": "Hello world", "segments": []} }' # HTTP 200 # {"code": 200, "data": {"message": "Callback interface test successful.", "callback_data": {...}}} ``` ``` -------------------------------- ### Add TikTok Video Task (CURL) Source: https://github.com/evil0ctal/fast-powerful-whisper-ai-services-api/blob/main/README.md Use this cURL command to add a video task to the TikTok processing queue. Ensure the server is running locally and all parameters are correctly formatted. ```curl curl -X 'POST' \ 'http://127.0.0.1/api/tiktok/video_task' \ -H 'accept: application/json' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'priority=normal&prepend_punctuations=%22'\''%E2%80%9C%C2%BF(%5B%7B-&no_speech_threshold=0.6&clip_timestamps=0&url=https%3A%2F%2Fwww.tiktok.com%2F%40taylorswift%2Fvideo%2F7359655005701311786&word_timestamps=false&platform=tiktok&temperature=0.8%2C1.0&task_type=transcribe&callback_url=&hallucination_silence_threshold=0&language=&condition_on_previous_text=true&compression_ratio_threshold=1.8&append_punctuations=%22'\'''.%E3%80%82%2C%EF%BC%8C!%EF%BC%81%3F%EF%BC%9F%3A%EF%BC%9A%E2%80%9D)%5D%7D%E3%80%81&initial_prompt=' ``` -------------------------------- ### Query Tasks with Filters Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Paginated query over all stored tasks. Supports filtering by status, priority, date range, language, engine name, and whether a result or error is present. Returns a list of matching tasks, total count, and a `next_offset` for cursor-based pagination. ```APIDOC ## POST /api/whisper/tasks/query ### Description Paginated query over all stored tasks. Supports filtering by status, priority, date range, language, engine name, and whether a result or error is present. Returns a list of matching tasks, total count, and a `next_offset` for cursor-based pagination. ### Method POST ### Endpoint /api/whisper/tasks/query ### Parameters #### Request Body - **status** (string) - Optional - Filter tasks by status (e.g., `queued`, `processing`, `completed`, `failed`). - **priority** (string) - Optional - Filter tasks by priority (`low`, `normal`, `high`). - **engine_name** (string) - Optional - Filter tasks by the inference engine used (e.g., `faster_whisper`). - **language** (string) - Optional - Filter tasks by the language of the audio. - **has_result** (boolean) - Optional - Filter for tasks that have a result. - **has_error** (boolean) - Optional - Filter for tasks that have an error. - **limit** (integer) - Optional - The maximum number of tasks to return per page. Defaults to 10. - **offset** (integer) - Optional - The number of tasks to skip for pagination. Defaults to 0. ### Request Example ```bash curl -X POST "http://localhost/api/whisper/tasks/query" \ -H "Content-Type: application/json" \ -d '{ "status": "completed", "priority": "normal", "engine_name": "faster_whisper", "language": "en", "has_result": true, "has_error": false, "limit": 10, "offset": 0 }' ``` ### Response #### Success Response (200) - **code** (integer) - HTTP status code (200 for success). - **data** (object) - Contains the query results: - **tasks** (array) - A list of matching task objects. - **total_count** (integer) - The total number of tasks matching the query. - **has_more** (boolean) - Indicates if there are more tasks available beyond the current result set. - **next_offset** (integer) - The offset to use for fetching the next page of results. #### Response Example ```json { "code": 200, "data": { "tasks": [{"id": 1, "status": "completed", ...}, ...], "total_count": 55, "has_more": true, "next_offset": 10 } } ``` ``` -------------------------------- ### Extract Audio from Video Source: https://context7.com/evil0ctal/fast-powerful-whisper-ai-services-api/llms.txt Accepts a video file upload and returns the extracted audio as a downloadable WAV or MP3 file. ```APIDOC ## Extract Audio from Video ### `POST /api/whisper/extract_audio` Accepts a video file upload and returns the extracted audio as a downloadable WAV or MP3 file. The temporary files are deleted automatically after the response is sent. ```bash curl -X POST "http://localhost/api/whisper/extract_audio" \ -F "file=@/path/to/video.mp4" \ -F "sample_rate=44100" \ -F "bit_depth=2" \ -F "output_format=mp3" \ --output extracted_audio.mp3 # Returns binary audio/mp3 file content with: # Content-Disposition: attachment; filename="extracted_audio.mp3" ``` ```