Yunfi

Yunfi

tg_channel
github
email

Love Reading Book Fragrance Configuration Microsoft TTS Audiobook Docker Self-built Version

Introduction#

For those who don't want to tinker, deploying through Vercel may be more convenient. See iFreeTime Audiobook Microsoft AI Voice TTS Vercel Deployment Tutorial | Yunfi's Blog for details.

Prerequisites#

  • A machine capable of running Docker
  • Docker installed

Refer to the "Installing Docker" section of this article: #Installing Docker | Yunfi's Blog

Installing the Server-side#

Installation#

# Create a folder with any name
mkdir ifreetime_tts && cd ifreetime_tts

# Download the file
wget https://gist.github.com/yy4382/d0c2a5e2c19323f4aa651f99317fd53e/raw/docker-compose.yml

# Start the container
docker compose up -d
# Done! Verify if it is successful using the method described below, and then configure it in iFreeTime.

If you want to set a token, follow the instructions in the yaml file.

Configuring iFreeTime on iOS#

Refer to the Vercel Deployment Tutorial | iFreeTime Configuration Section , the only difference is the address, which should be https://ip:3000/api/aiyue

If you have any issues, please leave a comment.

Appendix#

This is the initial version I made, which is quite complicated and is for reference only.

It may be a bit troublesome and requires basic knowledge of Docker, but it can help you understand how everything works. It is placed at the end of the article.

ms-ra-forwarder#

Example

You can also use Vercel, but it only provides 100GB of free traffic per month, so be careful if you listen a lot or have other services running.

  • Because Microsoft has closed the trial of Azure, we can only use the ra (edge's loud reading) interface.

ifreetime#

  • Project address: iranee/ifreetime: Self-hosted iOS iFreeTime TTS Service (github.com)

  • If you already have a server running a website that supports PHP, just change the IP in the ra.php file to the one you used in the first step, and then put it in the website.

  • If not, you need to create a Docker container to run the PHP file (Warning: I have never written PHP before, the Dockerfile syntax was provided by ChatGPT, so I can't guarantee it's optimal, but it should work, as I have succeeded).

  1. Create a new folder, let's call it ifreetime (or any other name).

  2. Enter the folder and create another folder called src, and put the ra.php file from the project into it (or clone the entire project directly).

  3. Modify ra.php, change http://127.0.0.1:3000/api/ra to the IP and port you generated in the first step

    • For servers, the easiest way is to use the public IP address + port, for Synology NAS, the simplest way is to use the LAN IP address + port.
    • Tested alternative solutions:
      1. After setting up domain name resolution and reverse proxy on a cloud server, use a format like https://tts.example.com/api/ra (using https://tts.example.com to access ms-ra-forwarder).
      2. Use the IP of the local Docker, usually 172.17.0.1, so it should be http://172.17.0.1:3000/api/ra.
    • Solutions that don't work: Cannot use 127.0.0.1 because it is inside the container.
    • Solutions that may cause problems: Domain name + port format, such as https://www.example.com:3000/api/ra, especially for NAS, because port 80/443 cannot be used, so an additional port must be added. Someone failed with this method, but it is not certain if it is due to this issue. If someone succeeds with this method, please email me (email address is written on the blog).
  4. Go back to the ifreetime folder and create a file called Dockerfile with the following content:

    # Set the base image
    FROM php:7.3
    
    # Copy the local code to the /var/www/html directory in the container
    COPY src/ /var/www/html/
    
    # Set the working directory inside the container
    WORKDIR /var/www/html
    
    # Expose port 8000 of the container
    EXPOSE 8000
    
    # Start the PHP server
    CMD ["php", "-S", "0.0.0.0:8000"]
    
  5. Build and run: In the ifreetime directory, enter the following commands one by one

    docker build -t ifreetime .
    docker run -d -p 12222:8000 ifreetime
    
  6. With this method, you need to replace all instances of 3000 with 12222 in the iFreeTime configuration (including during testing). Also, replace /api/aiyue with /ra.php.

  7. Open the iFreeTime app on your phone, go to Audiobook Configuration -> Custom Voice Library
    Create -> Advanced Custom Voice Synthesis

    Name: Any name

    Number of Characters: Recommended 200

    Request Method: GET

    Address: ra.php network address, if you installed it using the method above, it is http://your-ip:12222/ra.php

    Parameters -> Add -> Enter Request Parameter: voiceName, content is the desired voice (refer to here), for example, zh-CN-XiaoxiaoNeural

    Parameters -> Add -> Enter Request Parameter: text, content is %@

    Parsing Field -> Add -> Enter Parsing Field and Rule: playData, content is ResponseData

    Test Pronunciation, if it is correct, it's okay.

image
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.