Get comment id of the individual comments in comment list when modifying comment posted using comment text filter

The comment_text filter passes the comment as one of its params:

echo apply_filters( 'comment_text', $comment_text, $comment, $args );

So you don’t need to call get_comment_ID(), you can just access the ID from the $comment object.

Change:

add_filter( 'comment_text', 'modify_comment');

to:

add_filter( 'comment_text', 'modify_comment', 0, 3 );

And then:

function modify_comment( $comment_text, $comment, $args ){
    wp_enqueue_script( 'cmt-player', plugins_url( 'js/cmt-player.js',__FILE__ ), array( 'jquery' ), '', true );
    $comment_id = absint( $comment->comment_ID );
    $file_url = get_comment_meta( $comment_id, 'record_file', true );
    $site_parameters = array(
        'file_url'        => $file_url,
        'plugin_url'      => plugins_url(),
        'theme_directory' => get_template_directory_uri(),
        'comment_id'      => $comment_id,
    ); 
    wp_localize_script( 'cmt-player', 'wpvr_cmtvar', $site_parameters );
    require( 'lib/cmtplayer-interface.php' );
}

tech