npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amerandish/farsava

v0.3.1

Published

farsava javascript sdk

Downloads

3

Readme

Farsava Javascript SDK

نصب

<script src="farsava-sdk.js" type="text/javascript"></script>

یا

npm install @amerandish/farsava

استفاده

جهت استفاده از کیت توسعه فارس آوا ابتدا نیاز است یک آبجکت از Farsava.SDK درست کنید

| نام | توضیحات | | ------------------ | ----------------- | | <REST_API_BASEURL> | آدرس سرور API | | <ASR_LIVE_URL> | آدرس سرور وب سوکت | | <JWT_TOKEN> | توکن |

const sdk = new Farsava.SDK({
    baseUrl: "<REST_API_BASEURL>",
    liveUrl: "<ASR_LIVE_URL>",
    apiKey: "<JWT_TOKEN>",
});

سرویس ها


  • گفتار به نوشتار
  • نوشتار به گفتار
  • گفتار به نوشتار به صورت Live

مجموعه سرویس های گفتار به نوشتار

  • بررسی سلامت سرویس

| عنوان | نوع | توضیحات | | --------- | ------------------------------- | ------------- | | مدل ورودی | - | - | | مدل خروجی | Farsava.Models.HealthCheckModel | نتیجه درخواست |

  • async/await

    try {
        const response = await sdk.speech.healthCheck();
        // response model type is Farsava.Models.HealthCheckModel
        // handle response
    } catch (err) {
        // handle error
    }
  • then/catch

    sdk.speech
        .healthCheck()
        .then((response) => {
            // response model type is Farsava.Models.HealthCheckModel
            // handle response
        })
        .catch((err) => {
            // handle error
        });
  • تبدیل گفتار به نوشتار برای فایل های صوتی با زمان کمتر از ۱۵ ثانیه

| عنوان | نوع | توضیحات | | --------- | ------------------------------- | ------------------------------- | | مدل ورودی | Farsava.Models.ASRRequestModel | تنظیمات اولیه جهت ارسال درخواست | | مدل خروجی | Farsava.Models.ASRResponseModel | نتیجه درخواست |

  • async/await

    try {
        const base64AudioData = "";
        const config = new Farsava.Models.RecognitionConfigModel({
            audioEncoding: "LINEAR16",
            sampleRateHertz: 16000,
            languageCode: "fa",
            maxAlternatives: 1,
            profanityFilter: true,
            asrModel: "default",
            languageModel: "general",
        });
        const audio = new Farsava.Models.RecognitionAudioModel({
            data: base64AudioData,
        });
        const model = new Farsava.Models.ASRRequestModel({ config, audio });
        const response = await sdk.speech.asr(model);
        // response model type is Farsava.Models.ASRResponseModel
        // handle response
    } catch (err) {
        // handle error
    }
  • then/catch

    const base64AudioData = "";
    const config = new Farsava.Models.RecognitionConfigModel({
        audioEncoding: "LINEAR16",
        sampleRateHertz: 16000,
        languageCode: "fa",
        maxAlternatives: 1,
        profanityFilter: true,
        asrModel: "default",
        languageModel: "general",
    });
    const audio = new Farsava.Models.RecognitionAudioModel({
        data: base64AudioData,
    });
    const model = new Farsava.Models.ASRRequestModel({ config, audio });
    sdk.speech
        .asr(model)
        .then((response) => {
            // response model type is Farsava.Models.ASRResponseModel
            // handle response
        })
        .catch((err) => {
            // handle error
        });

مجموعه سرویس های نوشتار به گفتار

  • بررسی سلامت سرویس

| عنوان | نوع | توضیحات | | --------- | ------------------------------- | ------------- | | مدل ورودی | - | - | | مدل خروجی | Farsava.Models.HealthCheckModel | نتیجه درخواست |

  • async/await

    try {
        const response = await sdk.voice.healthCheck();
        // response model type is Farsava.Models.HealthCheckModel
        // handle response
    } catch (err) {
        // handle error
    }
  • then/catch

    sdk.voice
        .healthCheck()
        .then((response) => {
            // response model type is Farsava.Models.HealthCheckModel
            // handle response
        })
        .catch((err) => {
            // handle error
        });
  • تبدیل نوشتار به گفتار

| عنوان | نوع | توضیحات | | --------- | ------------------------------ | ----------------------------------------------------------- | | مدل ورودی | Farsava.Models.TTSRequestModel | تنظیمات اولیه جهت ارسال درخواست | | مدل خروجی | string | یک رشته حاوی اطلاعات صوت مورد نظر که به فرمت base64 می باشد |

  • async/await

    try {
        const text = "";
        const synthesisInput = new Farsava.Models.TTSSynthesisInputModel({
            text: text,
        });
        const voiceConfig = new Farsava.Models.TTSVoiceConfigModel({
            languageCode: "fa",
            voiceId: "b6e9c993-729e-4e0f-955b-f229cf1f77ee",
            name: "default",
            gender: "female",
        });
        const audioConfig = new Farsava.Models.TTSAudioConfigModel({
            audioEncoding: "LINEAR16",
            speakingRate: 1,
            pitch: 0,
            volumeGainDb: 0,
            sampleRateHertz: 22050,
            bitRate: 0,
        });
        const model = new Farsava.Models.TTSRequestModel({
            synthesisInput,
            voiceConfig,
            audioConfig,
        });
        const response = await sdk.voice.tts(model);
        // response model type is base64 string contain audio
        // handle response
    } catch (err) {
        // handle error
    }
  • then/catch

    const text = "";
    const synthesisInput = new Farsava.Models.TTSSynthesisInputModel({
        text: text,
    });
    const voiceConfig = new Farsava.Models.TTSVoiceConfigModel({
        languageCode: "fa",
        voiceId: "b6e9c993-729e-4e0f-955b-f229cf1f77ee",
        name: "default",
        gender: "female",
    });
    const audioConfig = new Farsava.Models.TTSAudioConfigModel({
        audioEncoding: "LINEAR16",
        speakingRate: 1,
        pitch: 0,
        volumeGainDb: 0,
        sampleRateHertz: 22050,
        bitRate: 0,
    });
    const model = new Farsava.Models.TTSRequestModel({
        synthesisInput,
        voiceConfig,
        audioConfig,
    });
    sdk.speech
        .asr(model)
        .then((response) => {
            // response model type is base64 string contain audio
            // handle response
        })
        .catch((err) => {
            // handle error
        });

مجموعه سرویس های گفتار به نوشتار Live

  • تبدیل گفتار به نوشتار

| عنوان | نوع | توضیحات | | --------- | ------------------------------- | ---------------------------------------------------------- | | مدل ورودی | string | یک رشته حاوی اطلاعات فایل ورودی که به base64 تبدیل شده است | | مدل خروجی | Farsava.Models.ASRResponseModel | نتیجه درخواست |

  • open socket connection

    sdk.live.openConnection((err, data) => {
        console.log("err", err);
        console.log("data", data);
    });
  • send with interval

    const CHUNK_SIZE = 16000;
    const INTERVAL_DURATION = 1000; // in milliseconds
    sdk.live.sendChunkAndInterval(base64AudioData);

مدل ها

  • مدل نتیجه درخواست سلامت سرویس (Farsava.Models.HealthCheckModel)

    | Field | Type | Required | Accept Values | | ------- | ------ | -------- | ------------- | | status | string | ✓ | | | message | string | ✓ | | | version | string | ✓ | |

  • مدل ارسال درخواست به سامانه تبدیل گفتار به نوشتار (Farsava.Models.ASRRequestModel)

    | Field | Type | Required | Accept Values | | ------ | ------------------------------------- | -------- | ------------- | | config | Farsava.Models.RecognitionConfigModel | ✓ | | | audio | Farsava.Models.RecognitionAudioModel | ✓ | |

  • مدل ارسال درخواست به سامانه تبدیل گفتار به نوشتار (Farsava.Models.RecognitionConfigModel)

    | Field | Type | Required | Accept Values | | --------------- | ------- | -------- | ------------- | | audioEncoding | string | ✓ | "LINEAR16" | | sampleRateHertz | number | ✓ | 16000 | | languageCode | string | ✓ | "fa" | | maxAlternatives | number | ✓ | 1 | | profanityFilter | boolean | ✓ | true | | asrModel | string | ✓ | "default" | | languageModel | string | ✓ | "general" |

  • مدل ارسال درخواست به سامانه تبدیل گفتار به نوشتار (Farsava.Models.RecognitionAudioModel)

    | Field | Type | Required | Accept Values | | ----- | ------ | -------- | ------------- | | data | string | ✓ | |

  • مدل نتیجه درخواست به سامانه تبدیل گفتار به نوشتار (Farsava.Models.ASRResponseModel)

    | Field | Type | Required | Accept Values | | --------------- | -------------------------------------------- | -------- | ------------- | | transcriptionId | string | ✓ | | | duration | number | ✓ | | | inferenceTime | number | ✓ | | | status | string | ✓ | | | results | Array[Farsava.Models.RecognitionResultModel] | ✓ | |

  • مدل نتیجه درخواست به سامانه تبدیل گفتار به نوشتار (Farsava.Models.RecognitionResultModel)

    | Field | Type | Required | Accept Values | | ---------- | ------------------------------------------ | -------- | ------------- | | transcript | string | ✓ | | | confidence | number | ✓ | | | words | Array[Farsava.Models.RecognitionWordModel] | ✓ | |

  • مدل نتیجه درخواست به سامانه تبدیل گفتار به نوشتار (Farsava.Models.RecognitionWordModel)

    | Field | Type | Required | Accept Values | | ---------- | ------ | -------- | ------------- | | startTime | number | ✓ | | | endTime | number | ✓ | | | word | string | ✓ | | | confidence | number | ✓ | |

  • مدل ارسال درخواست به سامانه تبدیل نوشتار به گفتار (Farsava.Models.TTSRequestModel)

    | Field | Type | Required | Accept Values | | -------------- | ------------------------------------- | -------- | ------------- | | synthesisInput | Farsava.Models.TTSSynthesisInputModel | ✓ | | | voiceConfig | Farsava.Models.TTSVoiceConfigModel | ✓ | | | audioConfig | Farsava.Models.TTSAudioConfigModel | ✓ | |

  • مدل ارسال درخواست به سامانه تبدیل نوشتار به گفتار (Farsava.Models.TTSSynthesisInputModel)

    | Field | Type | Required | Accept Values | | ----- | ------ | -------- | ------------- | | text | string | ✓ | |

  • مدل ارسال درخواست به سامانه تبدیل نوشتار به گفتار (Farsava.Models.TTSVoiceConfigModel)

    | Field | Type | Required | Accept Values | | ------------ | ------ | -------- | ---------------------------------------- | | languageCode | string | ✓ | "fa" | | voiceId | string | ✓ | "b6e9c993-729e-4e0f-955b-f229cf1f77ee" | | name | string | ✓ | "default" | | gender | string | ✓ | "female" |

  • مدل ارسال درخواست به سامانه تبدیل نوشتار به گفتار (Farsava.Models.TTSAudioConfigModel)

    | Field | Type | Required | Accept Values | | --------------- | ------ | -------- | ---------------------------------- | | audioEncoding | string | ✓ | "LINEAR16", "MP3", "OGG", "FLAC" | | speakingRate | number | ✓ | in range (0.5,2.0), step 0.1 | | pitch | number | ✓ | in range (-5, 5), step 1.0 | | volumeGainDb | number | ✓ | in range (-20, 20), step 1.0 | | sampleRateHertz | number | ✓ | 8000, 16000, 22050, 24000 | | bitRate | number | ✓ | 32, 64, 128, 198, 256, 320 |