Package: unrealspeech
Unreal Speech API Python PackageUnreal Speech Python SDK allows you to easily integrate the Unreal Speech API into your Python applications for text-to-speech (TTS) synthesis. This SDK provides convenient methods for working with the Unreal Speech API, including generating speech, managing synthesis tasks, and streaming audio.Table of ContentsGetting StartedInstallationObtaining an API KeyUsageInitializing the UnrealSpeechAPIGenerating SpeechManaging Synthesis TasksExamplesDocumentationContributingLicenseGetting StartedInstallationYou can install the Unreal Speech API Python package using pip:pipinstallunrealspeechTo ensure the package functions correctly, it is necessary to install the following dependencies as well.pipinstallplaysoundpydubsimpleaudioAvailable endpointsEndpointDescription/streamStream audio for short, time-sensitive cases/speechGenerate speech with options (MP3 format)/synthesisTasksManage synthesis tasks for longer text/synthesisTasks/TaskIdCheck the status of a synthesis taskCommon Request Body SchemaPropertyTypeRequired?Default ValueAllowed ValuesVoiceIdstringRequiredN/AScarlett, Liv, Dan, Will, AmyBitratestringOptional192k16k, 32k, 48k, 64k, 128k, 192k, 256k, 320kSpeedfloatOptional0-1.0 to 1.0PitchfloatOptional1.00.5 to 1.5Parameter DetailsVoiceId:Dan: Young MaleWill: Mature MaleScarlett: Young FemaleLiv: Young FemaleAmy: Mature FemaleBitrate:Defaults to 192k. Use lower values for low bandwidth or to reduce the transferred file size. Use higher values for higher fidelity.Speed:Defaults to 0. Examples:0.5: makes the audio 50% faster. (i.e., 60-second audio becomes 42 seconds)-0.5: makes the audio 50% slower. (i.e., 60-second audio becomes 90 seconds.)Pitch:Defaults to 1. However, on the landing page, we default male voices to 0.92 as people tend to prefer lower/deeper male voices.Rate LimitPlanRequests per secondFree1Basic2Pro8Obtaining an API KeyGet your API KeyTo use the Unreal Speech API, you'll need to obtain an API key by signing up for an account on the Unreal Speech website. Once you have an API key, you can use it to initialize the UnrealSpeechAPI class.UsageInitializing the UnrealSpeechAPIFirst, import the UnrealSpeechAPI class:fromunrealspeechimportUnrealSpeechAPI,play,saveThen, initialize the API with your API key:api_key='YOUR_API_KEY'speech_api=UnrealSpeechAPI(api_key)Generating SpeechYou can generate speech by providing a text string and optional parameters:text_to_speech="This is a sample text."timestamp_type="sentence"# Choose from 'sentence' or 'word'voice_id="Scarlett"# Choose the desired voiceaudio_data=speech_api.speech(text_to_speech,timestamp_type,voice_id)# Play audioplay(audio_data)Streaming AudioFor short and time-sensitive cases, you can use the /stream endpoint to stream audio:# Stream audiotext_to_stream="This is a short text to be synthesized."voice_id="Will"# Generate audio from textaudio_data=speech_api.stream("Example of using stream",voice_id,bitrate="192k")# Play audioplay(audio_data)Managing Synthesis TasksYou can manage synthesis tasks for longer text using the/synthesisTasksendpoint:# Create a synthesis tasktask_id=speech_api.create_synthesis_task(text_to_speech,voice_id,bitrate="320k",timestamp_type="word")# Check the task statusaudio_data=speech_api.get_synthesis_task_status(task_id)# Play audioplay(audio_data)Downloading AudioYou can download audio by simply calling the save functionfromunrealspeechimportsaveaudio_data=sppech_api.speech('How to download your audio easily')# you can use the save function to save the audiosave(audio_data,"output.mp3")ContributingContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.LicenseThis project is licensed under the MIT License - see the LICENSE file for details.