Skip to content

Commit

Permalink
Merge pull request #10 from zaai-ai/seamless
Browse files Browse the repository at this point in the history
  • Loading branch information
rjguedes8 authored Oct 9, 2024
2 parents 8147d10 + e111472 commit c4d92d1
Show file tree
Hide file tree
Showing 4 changed files with 420 additions and 0 deletions.
24 changes: 24 additions & 0 deletions seamless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Seamless

**Steps to run the code:**
1. Create a virtual environment with python 3.10.13
`conda create --name myenv python=3.10.13`
3. Activate in your new virtual environment
`conda activate myenv`
4. Install the required requirements
`pip install -r requirements.txt`
5. Create a folder called `/data` under `seamless/` and add your video
6. Run the notebook

## Folder Structure:
------------

├── seamless
├──────── data <- videos and audios
│──── requirements.txt <- package version for installing
│──── utils.py <- helper functions
└──── seamless.ipynb <- notebook to run the code
--------
4 changes: 4 additions & 0 deletions seamless/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
moviepy==1.0.3
jupyterlab==4.0.8
git+https://github.com/huggingface/transformers
sentencepiece==0.1.99
371 changes: 371 additions & 0 deletions seamless/seamless.ipynb

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions seamless/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from typing import Optional

import moviepy.editor as mp


def convert_to_wav(input_file: str, output_file: Optional[str] = None) -> None:
"""
Converts an audio file to WAV format using FFmpeg.
Args:
input_file (str): The path of the input audio file to convert.
output_file (str): The path of the output WAV file. If None, the output file will be created by replacing the input file
extension with ".wav".
Returns:
None
"""
if not output_file:
output_file = os.path.splitext(input_file)[0] + ".wav"

clip = mp.VideoFileClip(input_file)
clip.audio.write_audiofile(output_file, codec="pcm_s16le")

0 comments on commit c4d92d1

Please sign in to comment.