GithubHelp home page GithubHelp logo

Comments (1)

abhi2596 avatar abhi2596 commented on June 1, 2024
def convert_time_format(start_time, end_time):
    start_seconds = int(start_time)
    start_minutes = start_seconds // 60
    start_seconds %= 60
    start_milliseconds = int((start_time - int(start_time)) * 1000)

    end_seconds = int(end_time)
    end_minutes = end_seconds // 60
    end_seconds %= 60
    end_milliseconds = int((end_time - int(end_time)) * 1000)

    return f"{start_minutes:02d}:{start_seconds:02d}.{start_milliseconds:03d} --> {end_minutes:02d}:{end_seconds:02d}.{end_milliseconds:03d}"

def write_to_result(result, file_path):
    mode = "w"
    with open(file_path, mode, encoding="utf-8") as f:
        f.write("WEBVTT")
        f.write("\n\n")
        for segment in result["segments"]:
            f.write(f'{convert_time_format(segment["start"],segment["end"])}')
            f.write("\n")
            f.write( 
                (("[[" + segment["speaker"] + "]]") if "speaker" in segment else "") + " "
                + segment["text"].strip().replace("\t", " ")
            )
            f.write("\n\n")

from whisperx.

Related Issues (20)

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.