top of page
- Script Code -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_BRONZE")  

require("reaper_AZSTOKE_SILVER")   


function CutSilent(mediaItem)


    cutItemList = {}

    silentSectionList = reaper.AZ_GetAudioSectionListInMediaItem(mediaItem, 0.2)

    

    currentItem = mediaItem

    prevSplitPos = 0

    

    for i, section in pairs(silentSectionList) do

        leftItem, rigthItem = reaper.AZ_SplitMediaItem(currentItem, section["StartTime"] - prevSplitPos)

        prevSplitPos = section["StartTime"]

        reaper.AZ_DeleteMediaItem(leftItem)

        

        leftItem, rigthItem = reaper.AZ_SplitMediaItem(rigthItem, section["EndTime"] - prevSplitPos)

        prevSplitPos = section["EndTime"]

        

        currentItem = rigthItem

        

        table.insert(cutItemList, leftItem)

    end

    

    reaper.AZ_DeleteMediaItem(currentItem)

    

    return cutItemList


end


function Transcription(mediaItemList)


    -- モデルを読み込み

    ctx = reaper.AZ_TRSC_LoadModel()


    for i, item in pairs(mediaItemList) do


        track = reaper.GetMediaItemTrack(item)


        trscTrack = reaper.AZ_InsertUniqueChildTrack(track, "Transcription")

    

       -- 文字起こし実行

        text = reaper.AZ_TRSC_FullForMediaItem(ctx, item, "ja")

       

        itemStart = reaper.AZ_GetMediaItemStartTimeSeconds(item)

        itemLength = reaper.AZ_GetMediaItemLength(item)

       

        reaper.AZ_InsertNoteItemToTrack(trscTrack, itemStart, itemLength, text)

       

    end

    

    -- モデルを解放

    reaper.AZ_TRSC_ReleaseModel(ctx)

    

    return


end


function main()

    mediaItemList = reaper.AZ_GetSelectedMediaItemList(0)

    

    cutAllItemList = {}


    for i, item in pairs(mediaItemList) do


        cutItemList = CutSilent(item)

        

        for j, cutItem in pairs(cutItemList) do

            table.insert(cutAllItemList, cutItem)

        end

        

    end

    

    Transcription(cutAllItemList)

    

    reaper.AZ_ShowMessageBox_Info("音声の切り出しが完了しました。", "", reaper.AZ_WindowType_OK())

end


main()

- Warm Up -

Place audio files in Reaper in advance

- Script Detail -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_BRONZE")  

require("reaper_AZSTOKE_SILVER")  


・ Import RIGDOCKS


function CutSilent(mediaItem)


・ Function to extract silent parts of the audio


    cutItemList = {}

    silentSectionList = reaper.AZ_GetAudioSectionListInMediaItem(mediaItem, 0.2)


・ Get the silent parts of the audio (detect silences of 0.2 seconds or longer)

    

    currentItem = mediaItem

    prevSplitPos = 0


・ Initialize the current item and the previous split position

    

    for i, section in pairs(silentSectionList) do


・ Loop over the list of silent regions


        leftItem, rigthItem = reaper.AZ_SplitMediaItem(currentItem, section["StartTime"] - prevSplitPos)


・ Split the item at the start of the silent part and get the left and right items


        prevSplitPos = section["StartTime"]


・ Update the previous split position


        reaper.AZ_DeleteMediaItem(leftItem)


・ The left item is a silent part, so delete it

        

        leftItem, rigthItem = reaper.AZ_SplitMediaItem(rigthItem, section["EndTime"] - prevSplitPos)


・ Split the right item at the end of the silent part and get the left and right items


        prevSplitPos = section["EndTime"]


・ Update the previous split position

        

        currentItem = rigthItem

        

・ Update the current item to the right item (to split this item in the next loop)


        table.insert(cutItemList, leftItem)


・ Add the extracted item to the list


    end

    

    reaper.AZ_DeleteMediaItem(currentItem)


・ Also delete the last remaining item (the last item of the silent part)

    

    return cutItemList


・ Return the list of extracted items


end


function Transcription(mediaItemList)


・ Function to run transcription


    -- モデルを読み込み

    ctx = reaper.AZ_TRSC_LoadModel()


・ Load the model


    for i, item in pairs(mediaItemList) do


・ Loop over the media item list


        track = reaper.GetMediaItemTrack(item)


・ Get the track of the item


        trscTrack = reaper.AZ_InsertUniqueChildTrack(track, "Transcription")


・ Add a transcription child track to the track

    

       -- 文字起こし実行

        text = reaper.AZ_TRSC_FullForMediaItem(ctx, item, "ja")


・ Run transcription on the item (in Japanese)

       

        itemStart = reaper.AZ_GetMediaItemStartTimeSeconds(item)

        itemLength = reaper.AZ_GetMediaItemLength(item)


・ Get the item start time and length

       

        reaper.AZ_InsertNoteItemToTrack(trscTrack, itemStart, itemLength, text)


・ Insert the transcription result into the track as a note item

       

    end

    

    -- モデルを解放

    reaper.AZ_TRSC_ReleaseModel(ctx)


・ Release the model

    

    return


end


function main()

    mediaItemList = reaper.AZ_GetSelectedMediaItemList(0)


・ Get the list of selected media items

    

    cutAllItemList = {}


・ Initialize the list to hold the extracted items


    for i, item in pairs(mediaItemList) do


        cutItemList = CutSilent(item)


・ Call the function to extract silent parts for each item and get the list of extracted items

        

        for j, cutItem in pairs(cutItemList) do

            table.insert(cutAllItemList, cutItem)

        end

        

・ Add the extracted item to the list of all items


    end

    

    Transcription(cutAllItemList)


・ Run transcription on the list of extracted items

    

    reaper.AZ_ShowMessageBox_Info("音声の切り出しが完了しました。", "", reaper.AZ_WindowType_OK())


・ Notify the user that the process is complete


end


main()


・ Call the main function to start the process


- API LINK -
- API LINK -

Transcription

AZSTOKE_TRSC_CutSilent

Extract audio segments and transcribe

01_BRONZE_ss_edited.png
01_SILVER_edited_edited.png
03_GOLD_edited_edited.png
bottom of page