Coder Social home page Coder Social logo

0xspringtime / voicevox-anki Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 43 KB

Documentation on how to add voicevox support to anki cards

JavaScript 97.05% HTML 2.95%
anki anki-addon japanese-language tts voicevox text-to-speech ai japanese-study language-model speech-recognition

voicevox-anki's Introduction

voicevox-anki

Documentation on how to add voicevox support to anki cards

Method 1

  1. Download the Generate Batch Audio add-on from https://ankiweb.net/shared/info/1156270186 by copying and pasting the code 1156270186 into Tools > Add-ons > Get Add-ons

  2. Go to https://voicevox.su-shiki.com/su-shikiapis/ and at step 1, click the hyperlink at "こちら", then pass the reCAPTCHA to receive your API key at a new page in a field under "apiKeyをコピー", save this for later use. The API key has a daily limit but it is very high and multiple keys can be made by a single user.

  3. Now, go to the anki card browser and select all cards you would like to add voicevox tts to. Click Edit > Generate Bulk Audio. In the new window click "Add Source" and move the new field to the top in priority. This is important so the add-on uses voicevox first instead of the other sources.

  4. Now, to select the voice needed go to https://voicevox.hiroshiba.jp/ to preview all voices then, replacing {apiKey} with your saved key go to https://api.su-shiki.com/v2/voicevox/speakers/?key={apiKey} and find the id of your desired voice actress.

  5. Now, in the Bulk Generate Audio window Enter the Voicevox name then in custom URL add the url https://api.su-shiki.com/v2/voicevox/audio/?text={field}&key={API-KEY}&speaker={id} where API-KEY is your saved API key (no braces), {id} is your desired speaker (no braces), and {field} is the name of the field from which you would like tts generated WITH BRACES INCLUDED. The field may be any japanese text, including simply expressions as well as full sentences.

  6. In the audio field section pick the field you would like the audio placed in, and leave the "filter kana" and "delay between requests" fields empty.

  7. Click Generate and wait for your cards to generate! Let me know of any problems encountered in the "Issues" tab.

Method 2

  1. If you have voicevox downloaded, run with --host localhost --cors_policy_mod all
  2. Run node.js script like example used here
  3. Use http://localhost:3000/audio?text={AnkiField} as field in anki with Generate Batch Audio OR this as an example in your card to save disk space. To create a keybinding that resets audio one can use this

Method 3

  1. With voicevox downloaded, for a lightweight option one may opt to fetch the audio directly from within anki, without the need of a proxy using this within the anki card template editor.

voicevox-anki's People

Contributors

0xspringtime avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

voicevox-anki's Issues

Use local voicevox server

Hello. I think it would be great to add a note on how to use your own voicevox server with this guide.
Here's an example proxy for node (probably possible to rewrite in python, similar to https://github.com/jamesnicolas/yomichan-forvo-server):

import express from "express"
import fetch from "node-fetch"

const app = express();
app.listen(3000, () => {
    console.log("Server running on port 3000");
});

const host = 'http://localhost:50021'
const speaker = 0

app.get("/audio", async (req, res, next) => {
    const {text} = req.query
    console.log(`Got ${text}`)
    const audioQuery = await fetch(`${host}/audio_query?text=${text}&speaker=${speaker}`, {
        "method": "POST"
    })
    const meta = await audioQuery.json()

    const maybeWav = await fetch(`${host}/synthesis?speaker=${speaker}`, {
        "headers": {
            "content-type": "application/json",
        },
        "body": JSON.stringify(meta),
        "method": "POST",
    })
    res.setHeader('Content-Type', 'audio/wav')
    res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(text)}.wav"`);
    maybeWav.body.pipe(res);
})

This assumes that voicevox is running with --host localhost --cors_policy_mod all
Finally http://localhost:3000/audio?text={AnkiField} can be used as a source in generate-batch-audio-anki-addon or anywhere else really.

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.