Transforming Text to Speech with Awerks Neon TTS Cognitive Actions

24 Apr 2025
Transforming Text to Speech with Awerks Neon TTS Cognitive Actions

In the realm of application development, integrating advanced functionalities can significantly enhance user engagement and accessibility. The Awerks Neon TTS (Text-to-Speech) Cognitive Actions provide a powerful tool for developers looking to convert text into natural-sounding speech. With support for multiple languages, these actions enable applications to reach a broader audience by making content accessible to users regardless of their reading abilities.

Prerequisites

Before you start using the Awerks Neon TTS Cognitive Actions, ensure that you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of JSON since the input and output formats are structured in JSON.
  • Familiarity with making HTTP requests in your programming environment.

When making API calls, you will typically include your API key in the headers of your requests for authentication.

Cognitive Actions Overview

Convert Text to Speech with NeonAI Coqui

The Convert Text to Speech with NeonAI Coqui action allows developers to leverage the NeonAI Coqui AI TTS Plugin to convert text into audible speech. This action supports multiple languages, enhancing the accessibility of applications through high-quality voice synthesis.

  • Category: Text-to-Speech

Input

The input for this action requires a JSON object with the following fields:

  • text (required): The text that you want to convert to speech.
  • languageCode (optional): The language code representing the language of the input text, following ISO 639-1 standards. The default value is "en" (English).

Example Input:

{
  "text": "I still have the lease on the Michael Scott Paper Company, so occasionally I will sneak down here for a little coffee and dancing...",
  "languageCode": "en"
}

Output

Upon successful execution, the action returns a URL pointing to the generated audio file in WAV format. For example:

Example Output:

https://assets.cognitiveactions.com/invocations/d6b1e6fd-aa03-4edb-a0b0-c01dd0b67a5a/3b4bb8c1-d091-40a8-9890-3cfb56109c1e.wav

This URL can be used directly to play the speech audio in your application.

Conceptual Usage Example (Python)

To invoke the Convert Text to Speech with NeonAI Coqui action, you can use the following conceptual Python code snippet:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"  # Hypothetical endpoint

action_id = "eba77ad5-5c7e-402c-a99f-79f864c3d8de"  # Action ID for Convert Text to Speech with NeonAI Coqui

# Construct the input payload based on the action's requirements
payload = {
    "text": "I still have the lease on the Michael Scott Paper Company, so occasionally I will sneak down here for a little coffee and dancing...",
    "languageCode": "en"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}  # Hypothetical structure
    )
    response.raise_for_status()

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload are structured according to the specifications provided. The endpoint URL and request format are illustrative and should be replaced with actual values as needed.

Conclusion

The Awerks Neon TTS Cognitive Actions present a powerful resource for developers looking to enhance their applications with text-to-speech capabilities. By integrating these actions, you can provide a more inclusive experience for users, making content accessible in an engaging format. Explore the potential applications for this technology, from educational tools to accessibility features, and start transforming your text into immersive audio experiences!