create_voice (voice/factory.py)

gitingest_zhayujie_CowAgent · voice/factory.py · python · MIT
voice, tag:knn-classified

Factory function that returns a voice provider instance based on a string code.

# Source: https://github.com/zhayujie/CowAgent | License: MIT | Copyright 2022 zhayujie
# Provided via justclaw.it.com; keep this notice with the code.
"""
voice factory
"""


def create_voice(voice_type):
    """
    create a voice instance
    :param voice_type: voice type code
    :return: voice instance
    """
    if voice_type == "baidu":
        from voice.baidu.baidu_voice import BaiduVoice

        return BaiduVoice()
    elif voice_type == "google":
        from voice.google.google_voice import GoogleVoice

        return GoogleVoice()
    elif voice_type == "openai":
        from voice.openai.openai_voice import OpenaiVoice

        return OpenaiVoice()
    elif voice_type == "pytts":
        from voice.pytts.pytts_voice import PyttsVoice

        return PyttsVoice()
    elif vo

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key