Views
No views yet
1curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.python.sh | bash
2sudo apt-get install git-lfs
3git lfs installgit clone https://huggingface.co/k-m-irfan/Fastspeech2_HS_Flask_API1models
2├── hindi
3│ ├── female
4│ └── male
5├── tamil
6│ ├── female
7│ └── male
8.
9.
10.
11└── marathi
12 ├── female
13 └── male1python3 -m venv tts-hs-hifigan
2source tts-hs-hifigan/bin/activatepip install -r requirements.txt1python3 flask_app.py
2# OR
3gunicorn -w 2 -b 0.0.0.0:5000 flask_app:app --timeout 600bash start.sh1"""
2This is a sample API code to send a text to the server and recieve speech
3for the given text.
4
5Supported languages:
6
7Assamese, Bengali, Bodo, Gujarati, Hindi, Kannada, Malayalam, Manipuri
8Marathi, Odia, Punjabi, Rajasthani, Tamil, Telugu, Urdu
9
10"""
11import requests
12import json
13import base64
14
15# endpoint
16url = "http://localhost:5000/tts"
17
18lang = 'hindi'
19gender = 'female'
20text = "सुप्रभात, आप कैसे हैं?" # hindi
21# text = "സുപ്രഭാതം, സുഖമാ?" # malayalam
22# text = "সুপ্ৰভাত, তুমি কেনে?" # manipuri
23# text = "सुप्रभात, तुम्ही कसे आहात?" # marathi
24# text = "ಶುಭೋದಯ, ನೀವು ಹೇಗಿದ್ದೀರಿ?" # kannada
25# text = "बसु म्विथ्बो, बरि दिबाबो?" # bodo male yet to be added <---
26# text = "Good morning, how are you?" # english
27# text = "সুপ্ৰভাত, আপুনি কেমন আছে?" # assamese
28# text = "காலை வணக்கம், நீங்கள் எப்படி இருக்கின்றீர்கள்?" # tamil
29# text = "ସୁପ୍ରଭାତ, ଆପଣ କେମିତି ଅଛନ୍ତି?"
30# text = "सुप्रभात, आप कैसे छो?" # rajasthani
31# text = "శుభోదయం, మీరు ఎలా ఉన్నారు?" # telugu
32# text = "সুপ্রভাত, আপনি কেমন আছেন?" # bengali
33# text = "સુપ્રભાત, તમે કેમ છો?" # gujarati
34
35payload = json.dumps(
36 {
37 "input": text,
38 "gender": gender,
39 "lang": lang,
40 "alpha": 1 # to control speed
41 })
42
43headers = {'Content-Type': 'application/json'}
44response = requests.request("POST", url, headers=headers, data=payload).json()
45
46# save the received encoded audio
47audio = response['audio']
48file_name = "tts.wav"
49wav_file = open(file_name,'wb')
50decode_string = base64.b64decode(audio)
51wav_file.write(decode_string)
52wav_file.close()