la_lune_claire

Q: Command say and use to record multiples voices in one command

Hello,

 

I would like to know if it possible to use the command say with multiple voices together and to record it to a file.

 

For exemple, i would to record both "Good morning" from voice "Bruce" with also "Bonjour" from voice "Thomas" to a same file bonjour.aiff 

 

I would write the command this way but it doesn't work :

 

say -v Bruce "Good morning" -v Thomas "Bonjour" -o bonjour.aiff

 

Have you got any idea , after all it may be not possible in the native application.

 

Best regards.

 

Olivier

MacBook Pro (Retina, 13-inch, Mid 2014), iOS 9.3.2

Posted on May 22, 2016 9:33 AM

Close

Q: Command say and use to record multiples voices in one command

  • All replies
  • Helpful answers

  • by red_menace,Helpful

    red_menace red_menace May 22, 2016 11:25 AM in response to la_lune_claire
    Level 6 (15,526 points)
    Desktops
    May 22, 2016 11:25 AM in response to la_lune_claire

    You can't use say for that.  Depending on how serious you are, you can create multiple speech synthesizers or output files, but you would need to synchronize them - the various voices do not speak with the same timings.  You might be able to use something like a multi-track audio application to synchronize and save the output, otherwise you would need to use another utility (or write your own) to save the combined audio.

  • by la_lune_claire,Helpful

    la_lune_claire la_lune_claire May 22, 2016 11:25 AM in response to red_menace
    Level 1 (4 points)
    Mac OS X
    May 22, 2016 11:25 AM in response to red_menace

    Ok thanks for your answer. I found it strange you say it is not possible despite all the possibilities given here :https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/ SpeechSynthesisProgrammingGuide/FineTuning/FineTuning.html

    .

    If it is not possible as you said it, at the end i arrive at the same conclusion to do it on my own with utilities that can merge the obtained output files.

     

    Best regards,

     

    Olivier

  • by red_menace,

    red_menace red_menace May 22, 2016 12:09 PM in response to la_lune_claire
    Level 6 (15,526 points)
    Desktops
    May 22, 2016 12:09 PM in response to la_lune_claire

    The existing APIs (and say) provide ways to customize and save the speech output to a file, but they deal with individual voices.  Multiple voices will result in multiple files, so you can run multiple voices and capture the combined output, or you can combine multiple voice files.  Since you will need to synchronize the voices anyway (note that the exact speaking rate and the way the words themselves are spoken differ between voices), you could use something like Audacity to combine and synchronize to a single file.

  • by la_lune_claire,

    la_lune_claire la_lune_claire May 22, 2016 1:32 PM in response to red_menace
    Level 1 (4 points)
    Mac OS X
    May 22, 2016 1:32 PM in response to red_menace

    Thank you

  • by Roote,

    Roote Roote May 24, 2016 1:48 AM in response to la_lune_claire
    Level 2 (417 points)
    May 24, 2016 1:48 AM in response to la_lune_claire

    Hi Olivier. If you don’t mind installing additional components, one option is to use the command line sound processing utility SoX to mix individual audio files. If not installed, install the Homebrew package manager from Terminal:

     

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

     

    Then install SoX:

     

    brew install sox

     

    The following series of commands will create two /tmp audio files (automatically deleted by the system after a preconfigured period of time), mix them together, and place the mixed audio file on the Desktop. Copy and paste the following as a block into Terminal:

     

    say -v Thomas "Bonjour" -o /tmp/bj.aiff &&

    say -v Bruce "Good morning" -o /tmp/gm.aiff &&

    sox -m /tmp/bj.aiff /tmp/gm.aiff ~/Desktop/bonjour.aiff

     

    For best results use enhanced-quality voices. Because overlapping speech can create an aural muddle with poor distinction between the speech parts, you can add silence with the silence command [[slnc]] in milliseconds to adjust the amount of overlap. For instance:

     

    say -v Thomas "Bonjour" -o /tmp/bj.aiff &&

    say -v Bruce "[[slnc 300]] Good morning" -o /tmp/gm.aiff &&

    sox -m /tmp/bj.aiff /tmp/gm.aiff ~/Desktop/bonjour.aiff

     

    If you want to play the speech synthesizers simultaneously and record to file from the command line without creating individual temp files, first install GNU parallel with Homebrew from Terminal:

     

    brew install parallel

     

    Use the following command and follow the directions to silence the citation notice:

     

    parallel --bibtex

     

    Additionally, download and install either iShowU Audio Capture or Soundflower to be able to capture system sound. Once installed, open the Audio MIDI Setup app located in /Applications/Utilities/. Press the '+' button in the bottom left corner and select "Create Multi Output Device”.

    create.png

    If using iShowU Audio Capture, select both "Built-in Output” and "iShowU Audio Capture” in the right side panel. If using Soundflower, select both "Built-in Output” and "Soundflower (2ch)”. In either case, if selected, deselect “Drift Correction” as a starting point. You can change the name from Multi-Output Device in the left side panel by clicking on it.

    multi.png

    With either iShowU Audio Capture or Soundflower, select the corresponding Multi-Output-Device in the left side panel, click the gear icon in the bottom left and select "use this device for sound output”.

    output.png

    Still in the left side panel, select either "iShowU Audio Capture” or "Soundflower (2ch)”, click the gear icon in the bottom left and select “use this device for sound input”. In the right side panel, click the Input button and reduce the master volume (M) to a value of 0.96 or less to prevent clipping.

    input.png

    Note the microphone and speaker icons for the currently selected input and output. You can also select input and output devices by navigating to  > System Preferences > Sound.

     

    In Terminal, use the following piped  commands which will place an audio file on the Desktop:


    parallel ::: 'say -v Bruce "Good morning"' 'say -v Thomas "Bonjour"' | rec ~/Desktop/bonjour.aiff trim 0 00:02

     

    Adjust the recording time, 2 seconds in the above example (00:02), as necessary.

    terminal.png

    Tested with OS X Yosemite 10.10.5

  • by Hiroto,

    Hiroto Hiroto May 24, 2016 10:07 AM in response to la_lune_claire
    Level 5 (7,281 points)
    May 24, 2016 10:07 AM in response to la_lune_claire

    Hello

     

    Here's another option to use ffmpeg. You may obtain pre-compiled binaries for OS X from the following source.

     

    http://www.ffmpegmac.net/

     

     

    Download the zip archive, expand it and copy ffmpeg, ffprobe and ffserver to, e.g., /usr/local/bin.

     

    E.g.,

     

     

    #!/bin/bash
    SITE='http://www.ffmpegmac.net/resources'
    FILE='SnowLeopard_Lion_Mountain_Lion_Mavericks_Yosemite_El-Captain_02.05.2016.zip'
    DIR=~/Desktop/ffmpeg_install_temp
    
    # cd to temp directory
    mkdir -p "$DIR" && cd "$DIR" || exit
    
    # download zip archive
    curl -O "${SITE}/${FILE}" || exit
    
    # expand archive
    unzip -u "$FILE"
    
    # chown and copy files to /usr/local/bin
    sudo chown root:wheel ffmpeg ffprobe ffserver
    sudo cp -pPR ffmpeg ffprobe ffserver /usr/local/bin
    

     

     

     

    And here's a sample script to concatenate and/or mix audio files generated by say command using ffmpeg. I'd presume you're concatenating files rather than mixing them.

     

     

    #!/bin/bash
    
    DIR=~/Desktop/test
    mkdir -p "$DIR" && cd "$DIR" || exit
    
    say 'Good morning' -v Bruce -o 'good_morning.aiff'
    say 'Bonjour'      -v Ralph -o 'bonjour.aiff'
    
    FFMPEG=/usr/local/bin/ffmpeg
    
    # concatenate : using filter_complex, concat
    "$FFMPEG" \
        -i good_morning.aiff \
        -i bonjour.aiff \
        -filter_complex '[0:a] [1:a] concat=n=2:v=0:a=1 [aout]' \
        -map '[aout]' \
        -y \
        bonjour1.aiff
    
    # mix (mixdown to stereo) : using filter_complex amerge and -ac 2 option
    "$FFMPEG" \
        -i good_morning.aiff \
        -i bonjour.aiff \
        -filter_complex '[0:a] [1:a] amerge=inputs=2 [aout]' \
        -map '[aout]' \
        -ac 2 \
        -y \
        bonjour2.aiff
    
    # mix (file 1's L/R to output's L, file 2's L/R to output's R) : using filter_complex amerge, pan
    "$FFMPEG" \
        -i good_morning.aiff \
        -i bonjour.aiff \
        -filter_complex '[0:a] [1:a] amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3 [aout]' \
        -map '[aout]' \
        -y \
        bonjour3.aiff
    

     

     

     

    For complete documentation of ffmpeg, you may explore the following

     

    https://ffmpeg.org/documentation.html

     

     

    Scripts are tested under OS X 10.6.8.

     

    Good luck,

    H

  • by Roote,Solvedanswer

    Roote Roote May 24, 2016 11:21 AM in response to la_lune_claire
    Level 2 (417 points)
    May 24, 2016 11:21 AM in response to la_lune_claire

    To concatenate rather than mix using SoX:

     

    say -v Thomas "Bonjour" -o /tmp/bj.aiff &&

    say -v Bruce "Good morning" -o /tmp/gm.aiff &&

    sox /tmp/bj.aiff /tmp/gm.aiff ~/Desktop/bonjour.aiff

     

    SoX documentation

  • by la_lune_claire,

    la_lune_claire la_lune_claire May 24, 2016 1:06 PM in response to la_lune_claire
    Level 1 (4 points)
    Mac OS X
    May 24, 2016 1:06 PM in response to la_lune_claire

    Hello Hiroto,

    Hello Roote,

     

    Thank you very much for this help abundant in details and rigorous.

    I really appreciate.

     

    These are solutions and are helpful but i prefer one, it is using ffmpeg.

     

    First of all, i don't want to install brew like that, i prefer to keep my mac clean from it (may be i will use it in the future but not now).

    And luckily you can use pre-compiled sox in here : https://sourceforge.net/projects/sox/files/sox/ , for mac.

     

    So also you can use ffmpeg , and you nicely gave a bash script to do so that i will use.

     

    I have not yet studied Sox so far, but i guess i will be able to concatenate files like m4a more easily with ffmpeg.

    Work with aiff is good but if you have big files and running bash with these big files and concatenate it , it might become not so easy regarding the system.

     

    I have not yet tried but i think i will work with m4a, for reasons of vigilance and space.

     

    For your information, i'm just trying to read simultaneously the Coran in Arabic langage and french ; it is interesting and so also is "say" , full of possibilities.

     

    Thank you again,

     

    Olivier

     

    Best regards

  • by Roote,

    Roote Roote May 30, 2016 1:20 AM in response to la_lune_claire
    Level 2 (417 points)
    May 30, 2016 1:20 AM in response to la_lune_claire

    If using SoX to concatenate and wanting a .m4a file, you can use afconvert:


    say -v Thomas "Bonjour" -o /tmp/bj.aiff &&

    say -v Bruce "Good morning" -o /tmp/gm.aiff &&

    sox /tmp/bj.aiff /tmp/gm.aiff /tmp/bjgm.aiff &&

    afconvert -f m4af /tmp/bjgm.aiff ~/Desktop/bonjour.m4a

     

    This will convert an 84 KB .aiff tmp file to a 12 KB .m4a file.

     

    For afconvert help on the command line:

     

    afconvert -h

     

    To print a list of supported file formats:

     

    afconvert -hf

  • by la_lune_claire,

    la_lune_claire la_lune_claire May 30, 2016 1:30 PM in response to Roote
    Level 1 (4 points)
    Mac OS X
    May 30, 2016 1:30 PM in response to Roote

    Hello Roote,

     

    See your message this morning, thank you, may be this will help for the futures and many others.

     

    Greetings,

     

    Olivier