Prerequisites
-
Existing Open AI Account
-
Creating OpenAI Account with New Mail or Mobile Number
-
Open https://openai.com
-
Click on
Sign Up
button -
Choose your preffered
Sign Up
method -
After logged in click here to see below options
-
-
Create a HuggingFace Account
-
Click on
Sign Up
button -
Enter your details and Click on
Sign Up
-
Verify your email address
-
Create a New Space in HuggingFace Account
-
Create PlayHT Account
-
Open https://play.ht/
-
Click on
Log in
-
Since you don't have an account, go to https://play.ht/signup/
-
Choose your preferred
Sign Up
method -
Account will be created and you will be redirected to your dashboard
-
-
Clone your Voice to PlayHT
-
Before cloning, get ready with a 45 second clean audio of your voice
-
Click on
+ Create a New Clone
-
Click on
Instant
-
Enter Voice Name and Upload the File
-
Click on
Create
-
Your voice will be cloned
-
-
Open the below provided Colab link
-
Copying Code to your Google Drive
Assign API Keys and User IDs
-
How to get OpenAI API Key?
-
Click on
+ Create new secret key
-
Copy the secret key for your use
-
Assign OpenAI API Key
-
How to get PlayHT User ID and PlayHT API Key?
-
Login to PlayHT - https://play.ht/
-
Generate the Secret Key
-
Replace
PLAY_HT_API_KEY
with Secret Key you copied -
Replace
PLAY_HT_USER_ID
with User ID you copied
-
Assign your Voice to a variable and set the URL to a variable
-
How to get your Voice ID
-
In the right side section, select the language
Python
-
Enter Authorization as
Bearer PLAY_HT_API_KEY
replacePLAY_HT_API_KEY
with your API Key refer here -
Enter X-USER-ID as your
PLAY_HT_USER_ID
refer here -
Click on
Try it!
-
If the Response says
200
then you have successfully created your Voice ID -
Copy the
id
from the Response likes3://.../.json
-
Now you can use that
id
in theget_payload
as a value for voice -
Replace
PLAY_HT_VOICE_ID
with your copiedid
-
Click on Play button to set the values
Assigning the values for template, prompt, and memory
-
You can update the first line of the template
You are a helpful assistant to answer user queries
with<Prompts>
given in Prompts and Examples -
Click on Play button
Initializing LLM Chain using OpenAI
-
Using
ChatOpenAI
method we are creating an LLM Chain -
Click on Play button
Define a function to generate the Audio response and Create a ChatInterface using the Gradio
-
We are defining a
chat_bot_response
to return either an audio response format if audio file is fetched properly or returns a string response if it is an error -
We are creating the ChatInterface from gradio and providing a function
chat_bot_response
and also examples -
Check for other arguments here
-
Click on Play button to create an interface
If you are getting any errors
-
Keep print statements to identify the issue
-
To identify the error you are getting please add
debug = True
while launching the gradio appif __name__ == "__main__": demo.launch(debug = True)
-
You can add try and except block to handle the errors
def get_text_response(user_message,history): try: response = llm_chain.predict(user_message = user_message) except Exception as e: print("Error:", e) try: print("Error:", e.error.message) response = "Failed to reply: " + e.error.message except Exception as e: response = "Failed to reply" return response
Login to Hugging Face from Google Colab
-
Create a Hugging Face token and Copy
-
Login to Hugging Face https://huggingface.co/
-
Click on
New token
-
Add a Name for the Token
-
Choose
write
Role for the Token -
Click on
Generate a token
-
Copy the Token
-
-
Click on Play button to enter Hugging Face Token
-
Now paste the Hugging Face token in the textbox provided and click on
Login
Adding Hugging Face Repository ID
Adding APIs to Hugging Face secrets
Load App and Requirements file
-
Click on Play button to download files
-
You can check downloaded files in the left side panel
-
You can edit the downloaded files
-
Click on the
app.py
file -
The file will be opened and you can edit the
template
section by referring to Prompts and Examples -
After editing the file don't forget to save, by pressing
⌃ + S
or⌘ + S
-