본문 바로가기

AI 소식/오픈소스 AI 모델

[오픈 소스 AI] 음성 스타일까지 복제하는 AI, Sesame을 소개합니다.

안녕하세요,

최근 AI 기술의 발전으로, 단순한 명령 수행을 넘어 사람처럼 자연스럽게 대화할 수 있는 음성 AI 모델들이 등장하고 있습니다. 이러한 모델은 목소리의 억양, 감정, 말투까지 표현할 수 있는 고도화된 음성 생성 기술을 기반으로, 실제 사람과 대화하는 듯한 경험을 제공합니다.

이번에 소개할 Sesame AI는 그런 대표적인 사례 중 하나로, 현재 데모 버전을 통해 직접 체험할 수 있으며, 일부 기능은 오픈소스로도 공개되어 있어 누구나 활용해볼 수 있습니다. 이 글에서는 Sesame 모델의 주요 특징과 직접 설치하여 사용하는 방법에 대해 알아보겠습니다.


반응형

Sesame이란

Sesame은 자연스럽고 생동감 있는 대화를 주고받을 수 있는 음성 기반 AI 모델입니다. 이 AI는 인간의 음성에서 감정과 맥락을 인식하고, 이에 맞는 자연스러운 방식으로 응답하는 것을 목표로 개발되고 있습니다. 기존의 음성 비서가 명령어 중심의 응답에 초점을 맞췄다면, Sesame은 사용자와 보다 유연하고 감정적인 상호작용이 가능하도록 설계되었습니다. 이를 통해 단순한 정보 전달을 넘어, 사용자의 의도와 감정에 맞춘 대화 경험을 제공합니다.

 

아래 데모 링크를 통해 Sesame을 직접 체험해보실 수 있습니다.

 

 

Sesame

We believe in a future where computers are lifelike. Where they can see, hear, and collaborate with us – as we do with each other. With this vision, we're designing a new kind of computer.

www.sesame.com

 

현재 Sesame은 일부 음성 생성 모델을 오픈소스로 공개하고 있습니다. 이 모델은 텍스트와 오디오를 입력받아, 음성의 목소리, 억양, 말투, 스타일 등을 학습한 뒤, 입력된 텍스트를 학습된 화자의 목소리로 읽어주는 기능을 제공합니다. 단순한 TTS(Text-to-Speech)를 넘어, 화자 맞춤형 음성 생성 모델로 이해하시면 됩니다.

 

 

주요 특징

  • Voice Presence (목소리의 존재감)
    감정, 억양, 타이밍 등을 반영해 사람처럼 느껴지는 자연스러운 목소리를 구현합니다.
  • Uncanny Valley (불쾌한 골짜기) 극복
    중립적이고 감정 없는 기존 음성의 한계를 넘어, 따뜻하고 감성적인 대화를 지향합니다.

 

 

라이선스

Sesame은 Apache 2.0 라이선스를 따릅니다. 이 라이선스는 상업적 사용을 포함해 누구나 자유롭게 소스 코드를 사용, 수정, 배포할 수 있도록 허용합니다. 다만, 소스 코드를 사용할 때는 원 저작자 및 라이선스에 대한 고지를 명시해야 하며, 코드를 수정한 경우에는 변경 사항을 명확히 밝혀야 합니다. 또한, Apache 2.0 라이선스는 소프트웨어에 대한 보증을 제공하지 않으므로, 사용에 따른 책임은 전적으로 사용자에게 있습니다.

 

 

Sesame 설치 및 실행

아래에서 소개하는 오픈소스 AI 모델은 Sesame 공식 페이지에서 제공되는 서비스와는 다른 모델입니다. 현재 공개된 Sesame 모델은 음성 생성 모델로, 실제 대화가 가능한 형태는 아니며, 원활한 상호작용형 대화를 제공하는 모델은 포함되어 있지 않습니다. 이 점 참고하시기 바랍니다.

목차
1. 실행 환경
2. Sesame 설치
3. Sesame 실행

 

 

 

1. 실행 환경

  • 운영체제 : Windows 11
  • python : 3.10.0
  • torch : 2.4.0
  • numpy : 1.26.4
  • bitsandbytes : 0.45.4
  • trition-windows : 3.2.0.post17
  • GPU : NVIDIA GeForce RTX 4060 Ti

 

 

2. Sesame 설치

Sesame을 실행하는데 필요한 파일들은 아래와 같습니다.

 

[필요 패키지 설치]

위에서 필요한 모델을 모두 설치하셨다면, 이제 필요한 패키지를 설치합니다.

# Windows PowerShell
pip install -r requirements.txt  # 필수 패키지 설치
pip install bitsandbytes trition-windows  # 필수 패키지 설치
pip install numpy==1.26.4  # numpy>=2.x.x 이상인 경우 에러가 발생, 다운그래이드

 

[Python 코드 수정]

Sesame 실행 코드 (깃허브)에서, 아래 두 코드의 Sesame 모델 경로Llama3 모델 경로를 사용자의 환경에 맞게 수정해 주세요.

  • run_csm.py : Sesame 모델에게 입력할 음성 파일 및 텍스트 제공
  • generator.py : Sesame 모델 및 Llama3 모델 경로

[run_csm.py]

# Python
import os
import torch
import torchaudio
from huggingface_hub import hf_hub_download
from generator import load_csm_1b, Segment
from dataclasses import dataclass
os.environ["NO_TORCH_COMPILE"] = "1"

# AI 모델에게 제공할 음성 파일 로컬 경로
prompt_filepath_conversational_a = "E:/ai_model/seasame/models/csm-1b/prompts/conversational_a.wav"
prompt_filepath_conversational_b = "E:/ai_model/seasame/models/csm-1b/prompts/conversational_a.wav"

# 입력한 음성 파일 텍스트로 제공
SPEAKER_PROMPTS = {
    "conversational_a": {
        "text": (
            "like revising for an exam I'd have to try and like keep up the momentum because I'd "
            "start really early I'd be like okay I'm gonna start revising now and then like "
            "you're revising for ages and then I just like start losing steam I didn't do that "
            "for the exam we had recently to be fair that was a more of a last minute scenario "
            "but like yeah I'm trying to like yeah I noticed this yesterday that like Mondays I "
            "sort of start the day with this not like a panic but like a"
        ),
        "audio": prompt_filepath_conversational_a
    },
    "conversational_b": {
        "text": (
            "like a super Mario level. Like it's very like high detail. And like, once you get "
            "into the park, it just like, everything looks like a computer game and they have all "
            "these, like, you know, if, if there's like a, you know, like in a Mario game, they "
            "will have like a question block. And if you like, you know, punch it, a coin will "
            "come out. So like everyone, when they come into the park, they get like this little "
            "bracelet and then you can go punching question blocks around."
        ),
        "audio": prompt_filepath_conversational_b
    }
}

def load_prompt_audio(audio_path: str, target_sample_rate: int) -> torch.Tensor:
    audio_tensor, sample_rate = torchaudio.load(audio_path)
    audio_tensor = audio_tensor.squeeze(0)
    # Resample is lazy so we can always call it
    audio_tensor = torchaudio.functional.resample(
        audio_tensor, orig_freq=sample_rate, new_freq=target_sample_rate
    )
    return audio_tensor

def prepare_prompt(text: str, speaker: int, audio_path: str, sample_rate: int) -> Segment:
    audio_tensor = load_prompt_audio(audio_path, sample_rate)
    return Segment(text=text, speaker=speaker, audio=audio_tensor)

def main():
    # Select the best available device, skipping MPS due to float64 limitations
    if torch.cuda.is_available():
        device = "cuda"
    else:
        device = "cpu"
    print(f"Using device: {device}")

    generator = load_csm_1b(device)

    prompt_a = prepare_prompt(
        SPEAKER_PROMPTS["conversational_a"]["text"],
        0,
        SPEAKER_PROMPTS["conversational_a"]["audio"],
        generator.sample_rate
    )
    prompt_b = prepare_prompt(
        SPEAKER_PROMPTS["conversational_b"]["text"],
        1,
        SPEAKER_PROMPTS["conversational_b"]["audio"],
        generator.sample_rate
    )

    # 출력 텍스트
    conversation = [
        {"text": "Hey how are you doing?", "speaker_id": 0},
        {"text": "Pretty good, pretty good. How about you?", "speaker_id": 1},
        {"text": "I'm great! So happy to be speaking with you today.", "speaker_id": 0},
        {"text": "Me too! This is some cool stuff, isn't it?", "speaker_id": 1}
    ]

... (이하 동일)

 

[generator.py]

# Python

def load_llama3_tokenizer():
    """
    https://github.com/huggingface/transformers/issues/22794#issuecomment-2092623992
    """
    
    # Llama3 모델 로컬 경로
    tokenizer_name = "E:/ai_model/seasame/models/Llama-3.2-1B"
    
    tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)
    bos = tokenizer.bos_token
    eos = tokenizer.eos_token
    tokenizer._tokenizer.post_processor = TemplateProcessing(
        single=f"{bos}:0 $A:0 {eos}:0",
        pair=f"{bos}:0 $A:0 {eos}:0 {bos}:1 $B:1 {eos}:1",
        special_tokens=[(f"{bos}", tokenizer.bos_token_id), (f"{eos}", tokenizer.eos_token_id)],
    )
    return tokenizer

def load_csm_1b(device: str = "cuda") -> Generator:

    # Sesame 모델 로컬 경로
    model = Model.from_pretrained("E:/ai_model/seasame/models/csm-1b")
    model.to(device=device, dtype=torch.bfloat16)

    generator = Generator(model)
    return generator

 

 

3. Sesame 실행

아래 명령어를 통해 Sesame을 실행합니다.

# Windows PowerShell
python run_csm.py

 

Sesame 음성 생성 과정

 

위 이미지와 같이 실행은 정상적으로 완료되었습니다. 하지만 실행 과정에서는 몇 가지 어려움이 있었습니다. 특히 GPU 사용을 위해 여러 시도를 했지만, 실행되지 않거나 다양한 오류가 발생하기도 했습니다. 또한 Sesame에서 공식적으로 안내하는 실행 방식을 따르더라도, 환경에 따라 여러 오류가 발생하는 경우가 있었습니다. 아직 개발 초기 단계이기 때문에 안정화가 충분히 이루어지지 않은 것으로 보입니다.


 

 

Sesame 데모에서 경험할 수 있었던 자연스럽고 생동감 있는 대화 음성은 매우 인상적이었습니다. 이러한 기술이 오픈 소스로 공개되었다는 소식에 큰 기대를 가지고 직접 사용해보았지만, 아직은 일부 기능에서 다듬어야 할 부분들이 있는 것으로 보입니다.

현재 깃허브와 허깅페이스를 통해 제공되는 모델은 데모 버전에서 사용된 모델의 미세 조정 이전 버전으로, 실제 서비스 수준의 자연스러운 대화를 구현하기 위해서는 추가적인 개발과 튜닝이 필요한 상황입니다.

 

앞으로의 발전이 더욱 기대되는 만큼, 관심 있으신 분들은 오픈소스 모델을 직접 실험해 보며 기술의 가능성을 함께 살펴보시는 것도 좋을 것 같습니다.

 

감사합니다. 😊

 

반응형