Code Monkey home page Code Monkey logo

Comments (11)

kxxt avatar kxxt commented on July 22, 2024

You can do it in two ways:

  1. Using aspeak API, but the API might change in future versions (The API is not considered stable now. That's why I didn't document it in README.md).

    from aspeak import Synthesizer

    Create a Synthesizer instance. Here is the constructor:

    class Synthesizer:
    def __init__(self, audio_config: speechsdk.audio.AudioOutputConfig = None, locale: str = 'en-US',
    voice: Union[str, None] = None, audio_format: speechsdk.SpeechSynthesisOutputFormat = None):

    For audio_config and audio_format, please refer to azure cognitive services documentation. You can also look at __main__.py and figure it out by yourself.

    Call text_to_speech/ssml_to_speech method at your choice:

    def text_to_speech(self, text: str) -> speechsdk.SpeechSynthesisResult:

    def ssml_to_speech(self, ssml: str) -> speechsdk.SpeechSynthesisResult:

  2. Using azure-cognitiveservices-speech directly.
    You can use aspeak to obtain a trial token (Note that the token will expire after a short period of time. A call to renew() will renew the token):

    from aspeak import Token
    token = Token()

    Then you can use Microsoft's official azure-cognitiveservices-speech with this trial token.
    Here is an example to create an instance of SpeechConfig using a trial token:

    import azure.cognitiveservices.speech as speechsdk
    cfg = speechsdk.SpeechConfig(auth_token=token.token, region=token.region)

from aspeak.

Funktionar avatar Funktionar commented on July 22, 2024

I did manage to synthesize it but over time it's stops working, so I assume it's the token being expired. I did try to make a define to renew the token on keyboard press but it didn't work, as it seemed like I needed to return it; could you give me a concrete example on how to refresh the token?

from aspeak.

kxxt avatar kxxt commented on July 22, 2024

I did manage to synthesize it but over time it's stops working, so I assume it's the token being expired. I did try to make a define to renew the token on keyboard press but it didn't work, as it seemed like I needed to return it; could you give me a concrete example on how to refresh the token?

If you are using the Synthesizer API, it should handle the expiration automatically.

If you just use aspeak as a way to obtain a token and then use azure-cognitiveservices-speech directly, you need to recreate the SpeechConfig object after you renewed the token.

from aspeak.

kxxt avatar kxxt commented on July 22, 2024

An easy to use python API is on the way(#12 ), I will provide examples after implementing that feature.

from aspeak.

Funktionar avatar Funktionar commented on July 22, 2024

Using the second method, I just can't call simply Token.renew(), doesn't work.

from aspeak.

kxxt avatar kxxt commented on July 22, 2024

Using the second method, I just can't call simply Token.renew(), doesn't work.

Yes, you need to recreate SpeechConfig and even SpeechSynthesizer after the renew.

from aspeak.

Funktionar avatar Funktionar commented on July 22, 2024

When will you get the API running?

from aspeak.

kxxt avatar kxxt commented on July 22, 2024

When will you get the API running?

Maybe I will release a preview version this weekend.

from aspeak.

kxxt avatar kxxt commented on July 22, 2024

When will you get the API running?

A prerelease version v2.0.0.dev1 has been released. I will write the documentations later. There are examples in https://github.com/kxxt/aspeak/tree/feat/api/src/examples

from aspeak.

kxxt avatar kxxt commented on July 22, 2024

The functional API has been stabilized in v2.0.0.dev2
Documentation available at https://github.com/kxxt/aspeak/blob/feat/api/DEVELOP.md

from aspeak.

kxxt avatar kxxt commented on July 22, 2024

from aspeak.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.