File size: 2,035 Bytes
d617e46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b7f935
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b757a48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import gradio as gr
from transformers import pipeline
import numpy as np

transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")

def transcribe(stream, new_chunk):
    sr, y = new_chunk
    y = y.astype(np.float32)
    y /= np.max(np.abs(y))

    if stream is not None:
        stream = np.concatenate([stream, y])
    else:
        stream = y
    return stream, transcriber({"sampling_rate": sr, "raw": stream})["text"]


demo = gr.Interface(
    transcribe,
    ["state", gr.Audio(sources=["microphone"], streaming=True)],
    ["state", "text"],
    live=True,
)

demo.launch()





import base64
import pandas as pd

# Example DataFrame
data = {'Column1': [1, 2], 'Column2': [3, 4]}
df = pd.DataFrame(data)

# Function to convert DataFrame to CSV and then encode to base64
def to_base64_csv(df):
    csv = df.to_csv(index=False)
    b64 = base64.b64encode(csv.encode()).decode()
    return f"data:text/csv;base64,{b64}"

# Function to convert DataFrame to TXT and then encode to base64
def to_base64_txt(df):
    txt = df.to_csv(index=False, sep='\t')
    b64 = base64.b64encode(txt.encode()).decode()
    return f"data:text/plain;base64,{b64}"

# Generate base64 encoded links
csv_link = to_base64_csv(df)
txt_link = to_base64_txt(df)

# Markdown format for hyperlinks in bold font with emojis
markdown_csv_link = f"**[📥 Download Dataset as CSV]({csv_link})**"
markdown_txt_link = f"**[📥 Download Dataset as TXT]({txt_link})**"

# Display as markdown (hypothetical, depends on how you render markdown in your application)
print(markdown_csv_link)
print(markdown_txt_link)




import gradio as gr

def process_live_input(input_stream):
    # Process the input stream here
    # Return the processed output for live update
    processed_output = some_processing_function(input_stream)
    return processed_output

iface = gr.Interface(fn=process_live_input, 
                     inputs=gr.inputs.Video(source="webcam", streaming=True), 
                     outputs="video")

iface.launch()