ウェブサイト検索

HuggingFace 1-Click モデルを使用したポッドキャスト スクリプトの自動化


ポッドキャスティングは、過去数十年にわたって、ニュースやエンターテイメントを作成および配信するための最も人気のあるツールの 1 つになりました。これにはさまざまな理由がありますが、アクセスのしやすさ、ほとんどが無料であること、ポッドキャストで取り上げられるトピックの多様性が最も大きな理由の 1 つです。新しいポッドキャストを開始することも、これらの理由から非常に人気のあるクリエイティブな取り組みです。

ポッドキャスト ライターを目指す人が直面する最大の課題の 1 つは、長いポッドキャストを作成するときにカバーする必要があるコンテンツの量が膨大であることです。ポッドキャストの長さはさまざまですが、Google Gemini によると、平均的なポッドキャストの長さは 1 エピソードあたり 20 ~ 40 分です。その結果、多くの新しいポッドキャスト ライターは、特にポッドキャスト自体にインスピレーションを与えた最初の素材をカバーした後、時間を埋める主題を見つけるのに苦労する可能性があります。

この記事では、ポッドキャスト ライター向けの潜在的なソリューションを共有したいと思います。それは、DigitalOcean の GPU ドロップレット上で実行される HuggingFace 1-Click モデルを使用した書き込みです。このツールは、Web 上の強力な NVIDIA GPU 上の HuggingFace モデルにアクセスする最速の方法をもたらし、執筆手順に最適なアシスタント ツールを提供します。あらゆるテーマのポッドキャスト コンテンツ作成システムのセットアップと実行に関するガイドに従ってください。

前提条件

  • Python コード: このチュートリアルでは Python コードを使用してモデルにアクセスします
  • ターミナル ナビゲーション: このチュートリアルではターミナル ウィンドウの簡単なナビゲーションが必要ですが、コードは提供されます。

1-Click HuggingFace モデル GPU ドロップレットのセットアップ

最初に行う必要があるのは、ポッドキャスト スクリプトを生成するようにマシンをセットアップすることです。 HuggingFace 1-click モデルを使用してパーソナル アシスタントを作成するためのガイドに記載されているのと同じセットアップ手順に従います。 (リンク)。このチュートリアルを続ける前に、利用可能なモデルとそのアクセス方法について説明しているこのチュートリアルの最初のいくつかのセクションを読むことをお勧めします。

まず、HuggingFace の公式ドキュメントに示されている手順に従って、新しい GPU ドロップレットを作成します。

1-Click モデル GPU ドロップレットを作成するための完全なステップバイステップ ガイドについては、次のビデオをご覧ください。新しいインスタンスの起動の詳細については、この記事をご覧ください。このリンクで利用可能なリソースを使用し続ける前に、利用可能な各モデルとそれに関連するコストを調査することをお勧めします。

マシンが起動したら、次のセクションに進みます。

パーソナルアシスタントの起動

続行するには、この記事用に開発したのと同じパーソナル アシスタント Gradio アプリケーションを起動します。これにより、スクリプトを開発するための機能的なプレイグラウンドが提供されます。あるいは、HuggingFace 1-click Models ドキュメントに示されている UNIX および Python スクリプトを使用することもできますが、このチュートリアルでは説明しません。

GPU ドロップレットのターミナル ウィンドウを開き、次のスクリプトを貼り付けます。

cd ../home
apt-get install python3-pip
pip install gradio tts huggingface_hub transformers datasets scipy torch torchaudio accelerate
touch personalAssistant.py
vim personalAssistant.py

これにより、デモに必要なパッケージがインストールされ、パーソナル アシスタントの実行に使用するスクリプトが作成されます。次に、vim テキスト エディタを作成して開きます。次のスクリプトをウィンドウに貼り付け、エスケープ キーに続いて :wq を入力して、変更を加えたファイルを保存します。

import gradio as gr
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
from threading import Thread
import os
from huggingface_hub import InferenceClient
import gradio as gr
import random
import time
from TTS.api import TTS
import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
from datasets import load_dataset
import scipy.io.wavfile as wavfile
import numpy as np


device = "cuda:0" if torch.cuda.is_available() else "cpu"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32

model_id_w = "openai/whisper-large-v3"

model_w = AutoModelForSpeechSeq2Seq.from_pretrained(
    model_id_w, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
)
model_w.to(device)

processor = AutoProcessor.from_pretrained(model_id_w)

pipe_w = pipeline(
    "automatic-speech-recognition",
    model=model_w,
    tokenizer=processor.tokenizer,
    feature_extractor=processor.feature_extractor,
    torch_dtype=torch_dtype,
    device=device,
)

client = InferenceClient(base_url="http://localhost:8080", api_key=os.getenv("BEARER_TOKEN"))
Example voice cloning with YourTTS in English, French and Portuguesetts = TTS("tts_models/multilingual/multi-dataset/bark", gpu=True)
get v2.0.2
tts = TTS(model_name="xtts_v2.0.2", gpu=True)

with gr.Blocks() as demo:
    chatbot = gr.Chatbot(type="messages")
    with gr.Row():
        msg = gr.Textbox(label = 'Prompt')
        audi = gr.Audio(label = 'Transcribe audio')
    with gr.Row():
        submit = gr.Button('Submit')
        submit_audio = gr.Button('Submit Audio')
        read_audio = gr.Button('Transcribe Text to Audio')
        clear = gr.ClearButton([msg, chatbot])
    with gr.Row():
        token_val = gr.Slider(label = 'Max new tokens', value = 512, minimum = 128, maximum = 1024, step = 8, interactive=True)
        temperature_ = gr.Slider(label = 'Temperature', value = .7, minimum = 0, maximum =1, step = .1, interactive=True)
        top_p_ = gr.Slider(label = 'Top P', value = .95, minimum = 0, maximum =1, step = .05, interactive=True)

    def respond(message, chat_history, token_val, temperature_, top_p_):
        bot_message = client.chat.completions.create(messages=[{"role":"user","content":f"{message}"},],temperature=temperature_,top_p=top_p_,max_tokens=token_val,).choices[0]['message']['content']
        chat_history.append({"role": "user", "content": message})
        chat_history.append({"role": "assistant", "content": bot_message})
        # tts.tts_to_file(bot_message, speaker_wav="output.wav", language="en", file_path="output.wav")

        return "", chat_history, #"output.wav"
    
    def respond_audio(audi, chat_history, token_val, temperature_, top_p_):  
        wavfile.write("output.wav", 44100, audi[1]) 
        result = pipe_w('output.wav')
        message = result["text"]
        print(message)
        bot_message = client.chat.completions.create(messages=[{"role":"user","content":f"{message}"},],temperature=temperature_,top_p=top_p_,max_tokens=token_val,).choices[0]['message']['content']
        chat_history.append({"role": "user", "content": message})
        chat_history.append({"role": "assistant", "content": bot_message})
        tts.tts_to_file(bot_message, speaker_wav="output.wav", language="en", file_path="output2.wav")
        tts.tts_to_file(bot_message,
                file_path="output.wav",
                speaker_wav="output.wav",
                language="en")
        return "", chat_history, #"output.wav"
    def read_text(chat_history):
        print(chat_history)
        print(type(chat_history))
        tts.tts_to_file(chat_history[-1]['content'],
                file_path="output.wav",
                speaker_wav="output.wav",
                language="en")
        return 'output.wav'


    msg.submit(respond, [msg, chatbot, token_val, temperature_, top_p_], [msg, chatbot])
    submit.click(respond, [msg, chatbot, token_val, temperature_, top_p_], [msg, chatbot])
    submit_audio.click(respond_audio, [audi, chatbot, token_val, temperature_, top_p_], [msg, chatbot])
    read_audio.click(read_text, [chatbot], [audi])
demo.launch(share = True)

次に、次のコマンドを入力してアプリケーションを実行できます。

python personalAssistant.py

次に出力される共有のパブリック リンクを開いて、ローカル ブラウザでアプリケーションにアクセスします。

ポッドキャストスクリプトの作成

パーソナル アシスタントを起動して開いたら、開始できます。

まず、テーマを決める必要があります。 1-click モデル GPU ドロップレットを強化する LLM は非常に汎用性が高く、当社が提供するほぼすべての主題をカバーできます。私たちの実験では、それぞれが昨年の最近の知識を示すかなり新しい知識ベースを持っています。この例では、新しいテクノロジーの破壊的な影響について議論することに焦点を当てたテクノロジー ニュース ポッドキャストを作成します。

入力プロンプトを作成するときは、触れたい各点をモデルに考慮させることが重要です。

入力例:

Write a podcast script where two people, George and Maya, discuss the implications of a theoretical new competitor to Apple's Iphone. Have the two discuss in detail the consequences of the release of this new phone, considering the political, economic, and social implications of the end of the dominance of the Iphone.

出力:

Episode Title: "The Rise of a New Challenger: Implications of a Theoretical iPhone Rival"
Intro Music
George: Welcome to "Tech Talk", the podcast where we dive into the latest trends and innovations in the world of technology. I'm your host, George.
Maya: And I'm Maya. Today, we're going to explore a hypothetical scenario that's been making waves in the tech industry: the release of a new competitor to Apple's iPhone.
George: That's right. Imagine a phone that's not only on par with the iPhone in terms of hardware and software, but also offers a unique user experience that could potentially disrupt the market.
Maya: Exactly. So, let's dive into the implications of such a scenario. George, if this new phone were to become a reality, what do you think would be the immediate consequences?
Breaking Point 1: Initial Reaction
George: Well, I think the biggest impact would be on Apple's stock price. If a new competitor is offering a similar product at a lower price point, Apple's sales would likely take a hit, which would reflect in their stock price.
Maya: That's a great point. And what about the impact on consumers? Would they be willing to switch to a new brand?
Breaking Point 2: Consumer Perspective
George: I think some consumers might be interested in trying out a new brand, especially if it offers a unique feature or user experience that the iPhone doesn't. But, at the same time, there's a lot of loyalty built into the iPhone ecosystem, so it would be interesting to see how consumers respond.
Maya: That's true. And what about the impact on the ecosystem itself? Would this new competitor disrupt the entire app market?
Breaking Point 3: Ecosystem Disruption
George: Ah, that's a great question. If a new phone were to gain significant market share, it could potentially disrupt the entire app market. Developers would need to create apps for multiple platforms, which could lead to a fragmentation of the market.
Maya: Exactly. And what about the impact on the economy? Would this new competitor create new jobs or disrupt existing ones?
Breaking Point 4: Economic Impact
George: Well, it's likely that the release of a new competitor would create new jobs in the manufacturing and development sectors, but it could also lead to job losses in industries that are closely tied to the iPhone ecosystem.
Maya: That's a good point. And what about the impact on politics? Would this new competitor have any implications for national security or trade policies?
Breaking Point 5: Political Implications
George: Ah, that's an interesting question. If a new competitor were to gain significant market share, it could potentially create new tensions in the trade space, especially if the new phone were to be manufactured in a country with which the US has a trade agreement.
Maya: Exactly. And finally, what about the social implications of this new competitor? Would it lead to a more diverse and inclusive tech industry?
Breaking Point 6: Social Impact
George: Well, I think it's possible that a new competitor could lead to a more diverse and inclusive tech industry, especially if the new phone were to be designed with accessibility features or other inclusive technologies.
Maya: That's a great point. And what about the potential for social change? Would this new competitor be able to challenge the dominant narratives around tech and society?
Breaking Point 7: Social Change
George: Ah, that's a great question. If a new competitor were to gain significant market share, it could potentially challenge the dominant narratives around tech and society, especially if the new phone were to be designed with a focus on social responsibility.
Maya: Exactly. Well, that's all the time we have for today. Thanks for joining us on this thought experiment, George.
Outro Music
George: Thanks for tuning in to "Tech Talk". Join us next time for more discussions on the latest trends and innovations in the world of technology.
Maya: And don't forget to subscribe to our podcast for more in-depth analysis and expert insights.
Outro Music Continues
Note: The breaking points are indicated where the conversation can be improvised, allowing for a more dynamic and engaging discussion.

これがモデルによってどのように自動的にフォーマットされるかを見てください。多数のブレークポイントにより、モデルを使用してコンテンツをさらに入力するためのスペースが提供されます。各ブレークポイントに追加のプロンプトを追加して、新しいスケルトンを複合スクリプトにさらに拡張できます。たとえば、「ブレーク ポイント 4: 経済的影響」のセグメント全体を入力し、セクションを具体化するための追加の指示を付けることができます。試したときに得られたものは次のとおりです。

## Input
Continue this conversation. Focus entirely on the political economic implications of a new competitor for the iPhone
"Breaking Point 4: Economic Impact
George: Well, it's likely that the release of a new competitor would create new jobs in the manufacturing and development sectors, but it could also lead to job losses in industries that are closely tied to the iPhone ecosystem.
Maya: That's a good point. And what about the impact on politics? Would this new competitor have any implications for national security or trade policies?"
## Output
George: That's a great question, Maya. The implications for national security and trade policies could be significant. The iPhone is a symbol of American innovation and technological prowess, and any disruption to the market could have broader implications for the US economy and its position in the world.
Maya: I see what you mean. But what about the competitor's country of origin? If it's a company from a country like China, for example, would that change the dynamics of trade policies and national security concerns?
George: Exactly. If the competitor is a Chinese company, it could lead to increased scrutiny of Chinese trade practices and potentially even calls for tariffs or other trade restrictions. This could have a ripple effect on the global economy and potentially lead to a trade war.
Maya: That's a scary prospect. And what about the impact on the US dollar? If the competitor is able to gain significant market share, could that lead to a decrease in the value of the dollar?
George: It's possible. A decrease in the value of the dollar could make American exports more expensive and potentially lead to inflation. This could have a negative impact on the US economy and potentially even lead to a recession.
Maya: I see what you mean. But what about the impact on Apple's stock price? If the competitor is able to gain significant market share, could that lead to a decline in Apple's stock price?
George: That's a good question. If the competitor is able to gain significant market share, it could lead to a decline in Apple's stock price, potentially by 10-20% or more. This could have a significant impact on the company's valuation and potentially even lead to a change in leadership.
Maya: Wow, that's a lot to consider. But what about the impact on consumers? Would a new competitor lead to lower prices and more innovation in the smartphone market?
George: Absolutely. A new competitor could lead to increased competition, which could drive down prices and lead to more innovation in the smartphone market. This could be a win for consumers, who could see better quality and more features at lower prices.
Maya: That's a great point. But what about the impact on Apple's ecosystem? If the competitor is able to gain significant market share, could that lead to a decline in the value of Apple's ecosystem, including its App Store and other services?
George: That's a good question. If the competitor is able to gain significant market share, it could lead to a decline in the value of Apple's ecosystem

ご覧のとおり、モデルには、関連する会話のトピックを提供する、アイデアに関するいくつかの顕著な考えが含まれています。その後、著者は私たちが作成したものを利用して、詳細、統計、情報に基づいた調査を追加して拡張し、既存の出力を更新および改良することができます。

最後に

1-Click HuggingFace モデルの多用途性を過小評価することはできません。これまでの実験では、記事のローカリゼーション、クローズドソースの競合に匹敵するパーソナルアシスタント、そして今度は完全なポッドキャストスクリプトを作成してきました。将来的には、プレミアの Text-to-Speech モデリング技術を使用してスクリプトの音声化を完全に自動化する実験を計画しており、完全に AI で生成されたポッドキャスティングのパイプラインが完成することがわかります。