Skip to content

Commit

Permalink
Add speech synthesis.
Browse files Browse the repository at this point in the history
  • Loading branch information
juliensalinas committed Apr 21, 2023
1 parent 25ca3e9 commit 9ee1b22
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,16 @@ client.sentiment("<Your block of text>")

The above command returns a JSON object.

### Speech Synthesis Endpoint

Call the `speech_synthesis()` method and pass the text you want to convert to audio:

```python
client.speech_synthesis("<Your block of text>")
```

The above command returns a JSON object.

### Summarization Endpoint

Call the `summarization()` method and pass the text you want to summarize.
Expand Down
16 changes: 16 additions & 0 deletions nlpcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,22 @@ def sentiment(self, text):

return r.json()

def speech_synthesis(self, text, voice=None):
payload = {
"text": text,
"voice": voice
}

r = requests.post(
"{}/{}".format(self.root_url, "speech-synthesis"), json=payload, headers=self.headers)

try:
r.raise_for_status()
except HTTPError as err:
raise HTTPError(str(err) + ": " + str(r.text))

return r.json()

def summarization(self, text, size=None):
payload = {
"text": text,
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

setup(
name='nlpcloud',
version='1.0.40',
version='1.0.41',
description='Python client for the NLP Cloud API',
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",
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",
packages=['nlpcloud'],
author='Julien Salinas',
author_email='all@juliensalinas.com',
Expand Down

0 comments on commit 9ee1b22

Please sign in to comment.