Skip to content

Commit 9ee1b22

Browse files
author
Julien Salinas
committed
Add speech synthesis.
1 parent 25ca3e9 commit 9ee1b22

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,16 @@ client.sentiment("<Your block of text>")
385385

386386
The above command returns a JSON object.
387387

388+
### Speech Synthesis Endpoint
389+
390+
Call the `speech_synthesis()` method and pass the text you want to convert to audio:
391+
392+
```python
393+
client.speech_synthesis("<Your block of text>")
394+
```
395+
396+
The above command returns a JSON object.
397+
388398
### Summarization Endpoint
389399

390400
Call the `summarization()` method and pass the text you want to summarize.

nlpcloud/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,22 @@ def sentiment(self, text):
440440

441441
return r.json()
442442

443+
def speech_synthesis(self, text, voice=None):
444+
payload = {
445+
"text": text,
446+
"voice": voice
447+
}
448+
449+
r = requests.post(
450+
"{}/{}".format(self.root_url, "speech-synthesis"), json=payload, headers=self.headers)
451+
452+
try:
453+
r.raise_for_status()
454+
except HTTPError as err:
455+
raise HTTPError(str(err) + ": " + str(r.text))
456+
457+
return r.json()
458+
443459
def summarization(self, text, size=None):
444460
payload = {
445461
"text": text,

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
setup(
44
name='nlpcloud',
5-
version='1.0.40',
5+
version='1.0.41',
66
description='Python client for the NLP Cloud API',
7-
long_description="NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text generation, image generation, blog post generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, tokenization, POS tagging, embeddings, and dependency parsing. It is ready for production, served through a REST API.\n\nThis is the Python client for the API.\n\nMore details here: https://nlpcloud.io\n\nDocumentation: https://docs.nlpcloud.io\n\nGithub: https://github.com/nlpcloud/nlpcloud-python",
7+
long_description="NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text generation, image generation, blog post generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, speech synthesis, tokenization, POS tagging, embeddings, and dependency parsing. It is ready for production, served through a REST API.\n\nThis is the Python client for the API.\n\nMore details here: https://nlpcloud.io\n\nDocumentation: https://docs.nlpcloud.io\n\nGithub: https://github.com/nlpcloud/nlpcloud-python",
88
packages=['nlpcloud'],
99
author='Julien Salinas',
1010
author_email='[email protected]',

0 commit comments

Comments
 (0)