- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.4k
Hume tts service #2518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Hume tts service #2518
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            9 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      05fb223
              
                Add hume to .env.example
              
              
                zgreathouse d9656cb
              
                add hume sdk for hume tts service
              
              
                zgreathouse b489de2
              
                adds hume tts service
              
              
                zgreathouse 4ffdabc
              
                add Hume example, small fixes
              
              
                ivaaan c1492c5
              
                fixes based on markbackman review
              
              
                ivaaan f1bbb7b
              
                Regenerate uv.lock after resolving merge conflicts
              
              
                ivaaan fdadb12
              
                upd Changelog
              
              
                ivaaan 1b51155
              
                upd evals
              
              
                ivaaan 7692301
              
                upd Hume version to 2
              
              
                ivaaan File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,118 @@ | ||||||||
| # | ||||||||
| # Copyright (c) 2024–2025, Daily | ||||||||
| # | ||||||||
| # SPDX-License-Identifier: BSD 2-Clause License | ||||||||
| # | ||||||||
|  | ||||||||
| import os | ||||||||
|  | ||||||||
| from dotenv import load_dotenv | ||||||||
|  | ||||||||
| from pipecat.frames.frames import LLMRunFrame | ||||||||
| from pipecat.pipeline.pipeline import Pipeline | ||||||||
| from pipecat.pipeline.runner import PipelineRunner | ||||||||
| from pipecat.pipeline.task import PipelineParams, PipelineTask | ||||||||
| from pipecat.processors.aggregators.llm_context import LLMContext | ||||||||
| from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair | ||||||||
| from pipecat.runner.types import RunnerArguments | ||||||||
| from pipecat.runner.utils import create_transport | ||||||||
| from pipecat.services.deepgram.stt import DeepgramSTTService | ||||||||
| from pipecat.services.hume.tts import HUME_SAMPLE_RATE, HumeTTSService | ||||||||
| from pipecat.services.openai.llm import OpenAILLMService | ||||||||
| from pipecat.transports.base_transport import BaseTransport, TransportParams | ||||||||
| from pipecat.transports.daily.transport import DailyParams | ||||||||
| from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams | ||||||||
|  | ||||||||
| load_dotenv(override=True) | ||||||||
|  | ||||||||
| # We store functions so objects (e.g. SileroVADAnalyzer) don't get | ||||||||
| # instantiated. The function will be called when the desired transport gets | ||||||||
| # selected. | ||||||||
| transport_params = { | ||||||||
| "daily": lambda: DailyParams( | ||||||||
| audio_in_enabled=True, | ||||||||
| audio_out_enabled=True, | ||||||||
| vad_analyzer=SileroVADAnalyzer(), | ||||||||
| ), | ||||||||
| "twilio": lambda: FastAPIWebsocketParams( | ||||||||
| audio_in_enabled=True, | ||||||||
| audio_out_enabled=True, | ||||||||
| vad_analyzer=SileroVADAnalyzer(), | ||||||||
| ), | ||||||||
| "webrtc": lambda: TransportParams(), | ||||||||
| } | ||||||||
|  | ||||||||
|  | ||||||||
| async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): | ||||||||
| logger.info(f"Starting bot") | ||||||||
|  | ||||||||
| stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) | ||||||||
|  | ||||||||
| tts = HumeTTSService( | ||||||||
| api_key=os.getenv("HUME_API_KEY"), | ||||||||
| # Replace with your Hume voice ID | ||||||||
| voice_id="f898a92e-685f-43fa-985b-a46920f0650b", | ||||||||
| ) | ||||||||
|  | ||||||||
| llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) | ||||||||
|  | ||||||||
| messages = [ | ||||||||
| { | ||||||||
| "role": "system", | ||||||||
| "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be converted to audio so don't include special characters in your answers. Respond to what the user said in a creative and helpful way.", | ||||||||
| }, | ||||||||
| ] | ||||||||
|  | ||||||||
| context = LLMContext(messages) | ||||||||
| context_aggregator = LLMContextAggregatorPair(context) | ||||||||
|  | ||||||||
| pipeline = Pipeline( | ||||||||
| [ | ||||||||
| transport.input(), # Transport user input | ||||||||
| stt, | ||||||||
| context_aggregator.user(), # User responses | ||||||||
| llm, # LLM | ||||||||
| tts, # TTS | ||||||||
| transport.output(), # Transport bot output | ||||||||
| context_aggregator.assistant(), # Assistant spoken responses | ||||||||
| ] | ||||||||
| ) | ||||||||
|  | ||||||||
| task = PipelineTask( | ||||||||
| pipeline, | ||||||||
| params=PipelineParams( | ||||||||
| enable_metrics=True, | ||||||||
| enable_usage_metrics=True, | ||||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set the sample rate here. 
        Suggested change
       
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will set the sample rate to  | ||||||||
| audio_out_sample_rate=HUME_SAMPLE_RATE, | ||||||||
| ), | ||||||||
| idle_timeout_secs=runner_args.pipeline_idle_timeout_secs, | ||||||||
| ) | ||||||||
|  | ||||||||
| @transport.event_handler("on_client_connected") | ||||||||
| async def on_client_connected(transport, client): | ||||||||
| logger.info(f"Client connected") | ||||||||
| # Kick off the conversation. | ||||||||
| messages.append({"role": "system", "content": "Please introduce yourself to the user."}) | ||||||||
| await task.queue_frames([LLMRunFrame()]) | ||||||||
|  | ||||||||
| @transport.event_handler("on_client_disconnected") | ||||||||
| async def on_client_disconnected(transport, client): | ||||||||
| logger.info(f"Client disconnected") | ||||||||
| await task.cancel() | ||||||||
|  | ||||||||
| runner = PipelineRunner(handle_sigint=runner_args.handle_sigint) | ||||||||
|  | ||||||||
| await runner.run(task) | ||||||||
|  | ||||||||
|  | ||||||||
| async def bot(runner_args: RunnerArguments): | ||||||||
| """Main bot entry point compatible with Pipecat Cloud.""" | ||||||||
| transport = await create_transport(runner_args, transport_params) | ||||||||
|  | ||||||||
| await run_bot(transport, runner_args) | ||||||||
|  | ||||||||
|  | ||||||||
| if __name__ == "__main__": | ||||||||
| from pipecat.runner.run import main | ||||||||
|  | ||||||||
| main() | ||||||||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # | ||
|         
                  markbackman marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| # Copyright (c) 2024–2025, Daily | ||
| # | ||
| # SPDX-License-Identifier: BSD 2-Clause License | ||
| # | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
07ad has been taken. Let's rename to 07ae.