utils.py 428 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import io
from typing import Any, Dict, List


INSTRUCTION = (
    "Listen to the audio <audio> and output what a human has said on it. Answer:"
)


def doc_to_text(doc: Dict[str, Any]) -> str:
    return INSTRUCTION


def doc_to_audio(doc: Dict[str, Any]) -> List[dict]:
    audio = {
        "array": doc["audio"]["array"],
        "sampling_rate": doc["audio"]["sampling_rate"],
    }

    audios = [audio]
    return audios