{"id":19426661,"url":"https://github.com/zetane/block-text-to-speech","last_synced_at":"2025-07-02T19:32:55.997Z","repository":{"id":244408787,"uuid":"815154609","full_name":"zetane/block-text-to-speech","owner":"zetane","description":"Provide a text message and the sample audio file to generate the audio for the text message in the voice provided in the audio file ","archived":false,"fork":false,"pushed_at":"2024-06-14T13:41:06.000Z","size":438,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-25T05:16:37.733Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zetane.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-14T13:19:47.000Z","updated_at":"2024-07-03T01:29:16.000Z","dependencies_parsed_at":"2024-06-14T15:01:42.809Z","dependency_job_id":"34dd20e2-9442-4f7f-8b57-ba92c8b0685e","html_url":"https://github.com/zetane/block-text-to-speech","commit_stats":null,"previous_names":["zetane/block-text-to-speech"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zetane/block-text-to-speech","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetane%2Fblock-text-to-speech","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetane%2Fblock-text-to-speech/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetane%2Fblock-text-to-speech/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetane%2Fblock-text-to-speech/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zetane","download_url":"https://codeload.github.com/zetane/block-text-to-speech/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetane%2Fblock-text-to-speech/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263203452,"owners_count":23430034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T14:08:32.397Z","updated_at":"2025-07-02T19:32:55.961Z","avatar_url":"https://github.com/zetane.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Text-to-Speech Conversion with TTS\n\nThis repository contains a script to convert textual descriptions into audio files using a text-to-speech (TTS) model. The script is designed to work with a specific TTS model from the `TTS` library.\n\n## Requirements\n\n- Python 3.x\n- PyTorch\n- TTS Library\n\n## Installation\n\n1. Clone the repository:\n\n```bash\npip install torch TTS\nUsage\nThe script provides a compute function to convert text to speech and save it as an audio file.\n\nFunction Definition\npython\nCopy code\ndef compute(prompt, audio_file_path):\n    \"\"\"Convert text to speech and save it as an audio file.\n\n    Inputs:\n        prompt (str): Textual description to be converted to audio.\n        audio_file_path (str): Path to an existing audio file for speaker adaptation.\n\n    Outputs:\n        result (dict of str): Dictionary containing the path to the output audio file.\n    \"\"\"\nInputs\nprompt (str): The text that you want to convert into speech.\naudio_file_path (str): The path to an existing audio file used for speaker adaptation.\nOutputs\nresult (dict of str): A dictionary containing the path to the output audio file.\nExample\nHere's an example of how to use the compute function:\n\npython\nCopy code\nimport torch\nfrom TTS.api import TTS\nimport builtins\n\ndef compute(prompt, audio_file_path):\n    \"\"\"Convert text to speech and save it as an audio file.\n\n    Inputs:\n        prompt (str): Textual description of audio.\n        audio_file_path (str): Path for audio file.\n\n    Outputs:\n        result (dict of str): List of Output file.\n    \"\"\"\n    # Backup the original input function\n    original_input = builtins.input\n\n    # Define a new function that always returns 'y'\n    def mock_input(prompt):\n        print(prompt + \"y\")  # Optionally print the prompt and response\n        return 'y'\n\n    # Replace the input function with the mock_input function\n    builtins.input = mock_input\n\n    # Initialize TTS\n    tts = TTS(\"tts_models/multilingual/multi-dataset/xtts_v2\").to(\"cpu\")\n\n    # Run TTS to convert text to speech\n    wav = tts.tts(text=prompt, speaker_wav=audio_file_path, language=\"en\")\n\n    # Convert text to speech and save to a file\n    tts.tts_to_file(text=prompt, speaker_wav=audio_file_path, language=\"en\", file_path=\"output.wav\")\n\n    # Append output file to results\n    result = [\"output.wav\"]\n\n    # Restore the original input function after operations\n    builtins.input = original_input\n\n    return {\"result\": result}\n\n# Example usage\nprompt = \"Hello, this is a test.\"\naudio_file_path = \"path/to/existing/audio.wav\"\noutput = compute(prompt, audio_file_path)\nprint(output)\nThis script uses the TTS library to perform the text-to-speech conversion. It adapts to the speaker's voice using an existing audio file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzetane%2Fblock-text-to-speech","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzetane%2Fblock-text-to-speech","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzetane%2Fblock-text-to-speech/lists"}